Is there a better alternative for -cp/CLASSPATH ?
mthornton at optrak.com
Wed Dec 14 01:39:49 PST 2011
On 13/12/11 16:21, Timothy Madden wrote:
> Is there a way to launch java applications (classes), without having
> to know and to specify where the .class files are installed all the
> time ?
> Currently I have to set CLASSPATH or use the -classpath option on the
> java command line every time I want to start a Java application (I
> hear it is recomanded I do not set CLASSPATH in advance, but instead
> set it, or use -cp, upon every invocation of java; this way every
> Java application is invoked with its own CLASSPATH).
> Is there no way I could type just:
> `java net.grinder.Grinder´
> without having to specify the installation files/directory for The
> Grinder ?
> Is there no such thing as a local registry/repository/catalog of
> installed java classes/jars, that the launcher could use ?
> Thank you,
> Timothy Madden
You can use the Class-Path entry in the manifest of the main jar file
(along with the Main-Class attribute). This works best if the additional
jar files are located relative to the main jar file.
More information about the discuss