Re: executable jars and libraries
Jan Helgesen wrote:
So on unix that it would followed unix semantics for library searching
and added an option that enables or disables honouring of the manifest
Not at all. Java is platform agnostic. To have made Java behave in a specific
manner on one platform and in a different manner on a different platform would
entirely defeat part of its main ethos.
What it does provide is the option to the end user to select where they get the
classpath from. The user can choose to specify the classpath themselves
(via -cp or CLASSPATH) or allow the jar specify it for them (-jar).
In the case of entirely independent jar, java
should also have the option to package everything inside a jar, but
still with the override argument to enable/disable, as mentioned above.
If it's an entirely independent jar why does it need to specify a classpath at
all? If it's not independent, but requires additional jars, it's perfectly
possible to distribute a jar which contains other jars, and have the end user
installation procedure unpack that jar and setup the correct directory layout.
The UNIX/Linux way of handling libraries is different. LD_LIBRARY_PATH is a hack
which has had to be applied in order to allow a user to specify where to find
libraries when the application itself is unable to find them because it
provides no mechanism for specifying a search path.
It is also dangerous, extremely so when allowed on setuid applications or when
inadvertently used by root. Sensible security precautions prevent any use of
LD_LIBRARY_PATH in these situations rendering any application which relies on
it completely useless.