Professional Java.JDK.5.Edition (Wrox)
.pdfPackaging and Deploying
Your Java Applications
This chapter describes how to package and deploy your Java applications including client-side and server-side applications. It discusses technologies like Java Web Start, JAR packaging, JAR signing, building WAR files, and CLASSPATH manipulation. You’ll walk through the different types of Java applications and get a brief introduction to each as well as information on a few useful utilities that you can use when creating, configuring, and deploying your own applications.
Examining Java CLASSPATHs
One of the most potentially frustrating aspects of Java is the classpath. If you have coded in Java even for a short length of time, you’re already familiar with the classpath. It is a system environment variable that directs the Java Virtual Machine (VM) to a set of classes and/or JAR files. This is how the VM knows where code used by the program resides.
At times, you wind up needing a class and have no idea which JAR file has this class. You might add a bunch of JAR files to your classpath, hoping you’ll accidentally add the right one in, never truly knowing which JAR files are not needed. Many people complain about DLL Hell on Windows, but a similar mismanagement of the classpath and the many files it points to can create the same situation with Java. If you use a development environment such as Eclipse, you are somewhat insulated from this problem because it is easy to manage your classpath through the GUI. However, in a deployment scenario, you may not have the luxury of a graphical tool to help manage the classpath. A seemingly small problem (one JAR left off the classpath, for example) may take seconds to fix if you know where the class is, or — if you don’t know — much longer.
Another problem with classpaths is length limits on the classpath environment variable imposed by the environment. I’ve seen more than one project with an insane number of JAR files (each with a long path) specified within the classpath. Sometimes, there is no great solution to this problem.