Asked by
maheswar
in
Computers & Technology
at
8:55 PM on April 23, 2009
alokgupta14's Answer
Most Desktop Java applications have a similar structure. They are installed from a system-independent (but package dependent!) installer. This usually installs everything in a single directory with subdirectories called bin, lib, jar, conf, etc. There is usually a main jar file containing the main executable classes. A shellscript is usually provided to run the main class so users do not have to invoke the Java interpreter directly. This shell script is usually quite complex, as it is generic across distros, and often includes special cases for different systems (ie: CYGWIN).
The lib directory, often contains bundled jar files that satisfy dependencies of the Java application. This makes it simple for a user to install the program (all dependencies included), but is a package developer's nightmare. It is a waste of space when several packages bundle the same dependency. This was not a big issue in the past when there were fewer desktop Java applications and libraries, and those that existed tended to be very large anyway. Things are different now...
Other files necessary to run the program are usually stored in the same folder as the main jar file, or a subdirectory thereof. Since Java programs don't know where their classes were loaded from, they usually need to be run from within this directory (i.e. the shell script should cd into the directory), or an environment variable is set to indicate the directory's location.
Answered at
10:05 AM on April 24, 2009
Read all answers