View Full Version : Java path
1st October 2004, 06:41 PM
Does anyone know how to setup the PATH for Java in Linux?
I have installed JDK1.5.0 to the following dir
And I am looking to have it that when I open the Konsole I can do javac or java etc from anywhere, without having to change directory?
So i can just do javac from anywhere no matter what my current working directory is?
1st October 2004, 06:51 PM
see this : http://www.fedoranews.org/tchung/sunjava/
1st October 2004, 10:03 PM
You can also simply add ":/usr/local/jdk1.5.0/bin" to your "PATH" line in ".bash_profile".
15th October 2004, 12:41 AM
You might also wish to add:
in your .bash_profile also.
15th October 2004, 04:20 AM
You might also wish to add...
Do NOT add a CLASSPATH! That went the way of the dodo with Java 1.3 - the JVM will automagically locate the runtime libraries and the "." (dot) is always assumed. This causes more problems than it (supposedly) solves, especially when using IDE's that manage the ClassPath themselves. Plus, this breaks the ability to use "executable" Jars at times...
15th October 2004, 04:45 AM
But what about "foreign" jars?
still need a CLASSPATH for them.
15th October 2004, 06:12 AM
Nope - you don't need to set $CLASSPATH to use other jars. There are two other mechanisms that you can use:
1) put the other jars in the .../jre/lib/ext directory (not recommended as this makes those jars available to every JVM run on the system);
2) use the -classpath (for javac) and -cp (for java) command-line options
#2 is quite ideal for use in scripts, since you can then use script variables to build up the ClassPath statically or dynamically.
If you feel that you absolutely need to use an environment $CLASSPATH, the recommended procedure is to do that only "locally" in a terminal process. That way you won't mess up other Java programs and the variable is gone when the terminal environment terminates. To be honest, the only time I use this last method is when I'm using WebLogic command-line utilities for the first couple of times, until I get a handle on what I need to put in a script.
One of the best reasons to not use $CLASSPATH (and option #1) is if you put, say xerces.jar in the $CLASSPATH and then invoke Ant (especially an older version). Which version of Xerces gets used: the one in the antlib or the one on the $CLASSPATH?
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.