Setting Java Path for Eclipse

Installed Eclipse 3.0.2 on a Dell Laptop running Slackware 10.0

Installed Java into /usr/local

This link gives a walkthrough to editing the /etc/profile file.

http://www.linuxforum.com/forums/index.php?showtopic=86431

———————————————————————————

The variable PATH needs to include the path to the java executable.

Best solution – set both variables for all users:

-remove the addition to /home/danny/.bash-profile (we’ll move it to /etc/profile)

-edit /etc/profile

add:

export JAVA_HOME=/home/danny/Development/Java/j2sdk1.4.2_05

export PATH=$PATH:$JAVA_HOME/bin

Home is not set to ../j2sdk1.4.2_05/jre/bin/java as that is an actual file, and it should be set to the top directory of java.

The PATH is set to incluse $JAVA_HOME/bin instead of $JAVA_HOME/jre/bin/ as I think that the former is the correct java to use for the sdk, though both look the same:

CODE
root@lfs:/opt/j2sdk/j2sdk/bin# ./java -version

java version “1.4.2_03″

Java(tm) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)

Java HotSpot(tm) Client VM (build 1.4.2_03-b02, mixed mode)

root@lfs:/opt/j2sdk/j2sdk/bin# cd ../jre/bin

root@lfs:/opt/j2sdk/j2sdk/jre/bin# ./java -version

java version “1.4.2_03″

Java(tm) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)

Java HotSpot(tm) Client VM (build 1.4.2_03-b02, mixed mode)

If it doesn’t work for you then try

export PATH=$PATH:$JAVA_HOME/jre/bin

instead

Once the profile is changed, bash needs to load the profile. You can login again, start another bash session (new console or konsole or whatever) or type:

source /etc/profile

check the settings have taken effect with:

echo $JAVA_HOME

echo $PATH

You may also want to set MANPATH to include $JAVA_HOME/man

export MANPATH=$MANPATH:$JAVA_HOME/man

if your distro uses /etc/man.conf then add the manpath to that instead.

add the line:

MANPATH /home/danny/Development/Java/j2sdk1.4.2_05/man

You mentioned CLASSPATH in the topic, this is from the Beyond Linux From Scratch instructions:

QUOTE


Handling CLASSPATH

When compiling packages, the CLASSPATH environment variable is used by JDK to locate classes at compile-time and run-time. It is tedious to add all the classes used to the CLASSPATH manually. You may add the following lines to your shell startup file to set CLASSPATH automatically to include all JAR files in a specified directory, which in the example below is /usr/lib/auto-java-classpath.

AUTO_CLASSPATH_DIR=/usr/lib/auto-java-classpath

if [ -z $CLASSPATH ]

then

CLASSPATH=.:$AUTO_CLASSPATH_DIR

else

CLASSPATH=$CLASSPATH:.:$AUTO_CLASSPATH_DIR

fi

for i in $(ls $AUTO_CLASSPATH_DIR/*.jar 2>/dev/null)

do

CLASSPATH=$CLASSPATH:$i

done

so you can modify that to use whatever directory you want to have your classes, and put it into /etc/profile

———————————————————————————

Leave a Reply