Developers who want to use the single utilities classes proposed in this chapter and the other of
this part of the topic can do so without importing many classes. On the other side, developers
can always take advantage of the utility library proposed in Appendix D. Here, we will discuss
the additional services this library provides apart from those supplied by the utility class in
Chapter 11. In this way, we will explain the code in this chapter as well.
When taking advantage of JNLP runtime services (for instance, the persistence service), devel-
opers make the implicit choice to run their applications on a JNLP Client. This could poten-
tially tamper the portability of their Java code. In such a case, a common technique is to
provide a thin implementation of those runtime services that will work even if the application
is launched without an assisting JNLP Client. We provide a set of classes that “emulates” a
JNLP Client—providing persistence, printing, and the other JNLP runtime services.
Of course, this technique has its shortcomings. In order to be lightweight (we don't want to
reimplement a JNLP Client from scratch), it must be implemented as a pure Java library to be
added with our deployed code. This way, our replacement mechanism for a JNLP Client can-
not have access to data such as JNLP files, system-dependent resources, and so on.
Furthermore, it may turn out to be incompatible with some real-world JNLP Clients. For
example, some data saved with our library cannot be restored by Java Web Start or OpenJNLP
clients. Indeed, such interoperability issues happen between different JNLP Clients as well, as
we observed in Chapter 2. Nevertheless, this library has many advantages:
• It can be used for limited testing within a development environment without setting up
the complete execution scenario for every minimal test.
•Even at execution time, a properly designed application can be run seamlessly as a com-
mon application or through a JNLP Client without renouncing to JNLP runtime services
in both modalities. This will ease application development because there is no need to
produce two different versions of the same code (a costly and complex solution)—one to
be run from a JNLP client and the other one to be run as a simple command-line-based
• The library implementation may be modified and fine-tuned to handle special cases as
We will not discuss here the details of such a library that are presented and discussed in
As a little example of the facilities provided by the support library, there is the localization fea-
ture (for instance, see line 57 in Listing 13.3) shown in the window title of Figure 13.6—the
Textuale application is running on an Italian locale.