views:

178

answers:

3

OK I have 2 different version of Java install on my machine (CentOS 5), the system defaults to 1.5.0_14 but I need to run a command on the command line with the newer version of Java. How can I pass the newer version in the command line?

Sorry this is such a n00b question but I googled and didn't find anything, thanks.

+4  A: 

Just use the full pathname for your java executable, rather than allowing the OS to pick one based on your PATH.

Visage
+3  A: 

Use the absolute path to the java executable:

/opt/java-1.4/bin/java

Robert Munteanu
A: 

You could make a link to the file:

ln myJava1 <java version you want>
ln myJava2 <java version you want>

and then when you want one or the other, type the appropriate link.

Or if you want a standard java and just have the other for one offs, you could do:

ln theJava <myJava1 or myJava2>

and then just use theJava (or whatever you want to call it

samoz