Is there a better alternative for -cp/CLASSPATH ?

Timothy Madden terminatorul at gmail.com
Wed Dec 21 14:18:50 UTC 2011


On 13.12.2011 19:50, Andrew Haley wrote:
> On 12/13/2011 04:21 PM, Timothy Madden wrote:
>> Is there no such thing as a local registry/repository/catalog of
>> installed java classes/jars, that the launcher could use ?
>
> This is one of the goals of Project Jigsaw:
>
> http://openjdk.java.net/projects/jigsaw/

I do believe a monolithic JDK can have disadvantages for non-PC systems, 
which jigsaw tries to address, but splitting it into modules will 
automatically lead to module dependencies, module version dependencies, 
maintained and un-maintained modules, deprecated modules, third-party 
modules ... and all that daunting stuff, and frankly I am not looking 
forward to another ".dll hel" within Java ... I find it easier to stick 
to a monolithic run-time.

Putting third-party modules/packages, on the other hand, put into a sort 
of java system-wide PATH / CLASSPATH / registry, that would make them 
directly available as soon as they are "installed", would be more 
appropriate (in other words, java should have modules, but only for 
user-provided/third-party classes/archives).

Which leads to the next question: what is wrong with CLASSPATH ?
Why is it recommended that CLASSPATH not be used, and that every java 
invocation use -cp instead ?

Also, using a "known place" for storing the java classes, like the Unix 
directory hierarchy where each directory (/etc, /usr/local, /usr/bin, 
/var, /tmp, /opt) is the "known place" for certain files, could also be 
used as a sort of an "alternative" to (or a first step toward) the 
system-wide PATH/CLASSPATH/registry method. But it is be more 
appropriate for .jar files, not necessarily for java class files.

I see Linux distributions try to do just that and install .jar files for 
most packages from the distribution in /usr/share/java.

Which makes me think I could also use /usr/local/share/java (or even 
/opt/share/java, although /opt/share is not specified in the Filesystem 
Hierarchy Standard) as a default value for CLASSPATH, breaking the 
recommended usage for CLASSPATH, or in a sh (shell) alias for `java´, 
which will have about the same effect.

But I still think a better/standard way to reference installed java 
classes would be in order.

Thank you,
Timothy Madden




More information about the discuss mailing list