Click to See Complete Forum and Search --> : How do set path for java?
Giscardo
02-08-2001, 06:13 PM
Hello, I installed linux Mandrake on my computer last semester, and this semester we are programming in Java, using Java version 1.2.x. The version that came with my Mandrake 7.2 seems to be Kaffe Virtual Machine using java version 1.1. I installed two other java versions (Sun's JDK, ver 1.3, and one from Blackdown, ver 1.2.2). The respective paths of these installations are /usr/java/, and /usr/local/jdk1.2.2/. MY QUESTION IS, how do I make it so that when I type in "java" and "javac" (and any other java commands i might use in the future but don't know about right now), the computer runs the compiler/interpreter installed at /usr/local/jdk1.2.2/ instead of the Kaffe one that Mandrake installed? I am not sure as to where the Kaffe Java Virtual Machine is installed. THanks for reading this long post, and for any help you may provide,
Giscardo
Strike
02-08-2001, 07:13 PM
well, removing the ones you don't want is always good. Just do a rpm -qa | grep java or rpm -qa | grep kaffe to find those.
But, I normally just make symlinks to executables in /usr/bin, and have that directory in my path. For example:
[ddipaolo@half-life ddipaolo]$ which java
/usr/bin/java
[ddipaolo@half-life ddipaolo]$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Feb 8 01:16 /usr/bin/java -> /etc/alternatives/java
[ddipaolo@half-life ddipaolo]$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 25 Feb 8 01:16 /etc/alternatives/java -> /usr/lib/j2re1.3/bin/java
(that whole /etc/alternatives thing is a Debian thing, not something I did.
scott_R
02-09-2001, 01:12 AM
Go into your home directory, there should be a file called .bash_profile. (The . before the name means it's a hidden file, so you may have to set your file manager to list all files, or if you're in console, ls -a, to see it.
Open it up so you can edit it, then edit the line that starts with PATH=. Use a colon if you have more than one directory to add. If you have a directory to your kaffe listed (it should be obvious), you'll want to remove it from the path so you don't have a conflict.
Strike
02-09-2001, 01:44 PM
Just one thing about scott_R's way of doing it (which will, indeed, work): it tends to clutter up your path. My way just clutters up your /usr/bin directory with a bunch of symlinks. However, there are often other executables in the directories added to your PATH, so it may do more than you want to do...
justlinux.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.