View Full Version : Java 5.0 SDK setup, help please

22nd November 2004, 06:01 PM
I'm having probelms with the setup of J2SE, please some assistance would be appreciated

I have two entries in my path for the java bin, but still cannot run java from any folder?

I don't know how to set the links for javac as described in other posts?


# rpm -iv jdk-1_5_0-linux-i586.rpm

# rpm -e jdkgcj
... package not installed ...

# java -version
... placeholder message ...

/etc/profile.d/java.sh file created with single line
export PATH=$PATH:/usr/java/jdk*/bin

#source /etc/profile.d/java.sh
... verified path update ...

# alternatives --remove java /usr/share/java/libgcj-java-placeholder.sh

# alternatives --remove javac /usr/share/java/libgcj-javac-placeholder.sh
... has not been configured as an alternative for javac ...

# alternatives --remove jar /usr/bin/fastjar

# alternatives --remove jar.1.gz /usr/share/man/man1/fastjar.1.gz

# cd /usr/bin

# ln -s /usr/java/jre1.5.0/bin/java java

... don't know how to set the links for javac ??? ...

# java
bash: java: command not found

# /usr/java/jdk1.5.0/bin/java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

# set

22nd November 2004, 06:38 PM
It looks like you have installed BOTH the Java runtime environment, and the Java Developers kit and are getting the two mixed up.

Try setting these two environment variables.
export PATH=$PATH:/usr/java/jdk1.5.0/bin
export JAVA_HOME= /usr/java/jdk1.5.0

if you want a link to the javac binary in /usr/local say
then do this
"cd /usr/local"
"ln /usr/java/jdk1.5.0/bin/javac ."
"ln /usr/java/jdk1.5.0/bin/java ."

You probably need BOTH links, one to compile java source (javac), and one to actually run the java code (java)

22nd November 2004, 06:40 PM
Typoe in previous post, just as soon as I hit the post button I saw it.

"cd /usr/local/bin" (NOT "cd /usr/local")
"ln /usr/java/jdk1.5.0/bin/javac ."
"ln /usr/java/jdk1.5.0/bin/java ."

22nd November 2004, 06:53 PM
Yes I'm wanting to setup the development and runtime environments

To set the environment variables, is using 'etc/profile.d/java.sh' the best way to do this?

22nd November 2004, 06:59 PM
Personally, I just put the two lines

export PATH=$PATH:/usr/java/jdk1.5.0/bin
export JAVA_HOME= /usr/java/jdk1.5.0

in my "/etc/profile" file

22nd November 2004, 07:01 PM
By the way, you do NOT need to make the links in "/usr/local" IF you put the "export PATH=$PATH:/usr/java/jdk1.5.0/bin" in your "/etc/profile"...

I would actually recommend NOT using links, because if you upgrade your java compiler in the future, the links to the old version can cause problems....

22nd November 2004, 07:12 PM
You don't need to install both the SDK and the JRE - the SDK comes with the JRE in a separate binary directory (/path/to/sdk/jre/bin). In fact, you might actually confuse some applications and IDE's if you install both and put both in the path.

What I've done in the past is install the tarballs in /opt, create a soft-link (ln -s /opt/j2sdk1.4.2_04 /opt/java) and added the following to the /etc/profile file:

pathmunge /usr/X11R6/bin after

# this is the new stuff
pathmunge /opt/java after
export JAVA_HOME=/opt/java
# end of new stuff

unset pathmunge

This allows you to reset the basic SDK softlink as needed. Alterntatively (pun intented), I got the alternatives stuff figured out at http://fedoraforum.org/forum/showpost.php?p=128366&postcount=10

22nd November 2004, 07:48 PM
If I put the path and home statements in the '/etc/profile' then I won't need to have a '/etc/profile.d/java.sh' ?

Also, the linking thing is confusing me a little, I have checked the directory structure and can see that the JRE java file is located in both the /usr/java/jdk1.5.0/bin and /usr/java/jdk1.5.0/jre/bin directories, any suggestions about that ?

Once i have java and javac working, then I will want to install and configure a good java editor, i'm a little unsure about moving to an IDE at this stage?

22nd November 2004, 08:27 PM
If you use windows, then just think if "linking" as "creating a shortcut"....They are pretty much the same thing....

The "jre" subdirectory is the "Runtime" version for java. the binaries/programs for java. it doesn't include a compiler (no javac in the "jre/bin" subdirectory...)

If you stick with the "PATH and CLASSPATH" environment variables that I showed earlier, you should be okay....

PS: a good java editor/development platform is "eclipse" available from http://www.eclipse.org/

22nd November 2004, 08:28 PM
If I put the path and home statements in the '/etc/profile' then I won't need to have a '/etc/profile.d/java.sh' ?


22nd November 2004, 09:39 PM
If you stick with the "PATH and CLASSPATH" environment variables that I showed earlier, you should be okay....
Er, didn't you mean JAVA_HOME? Setting a "global" CLASSPATH is more likely to give you problems (especially when using multiple libraries).

PS: a good java editor/development platform is "eclipse" available from http://www.eclipse.org/
Seconded - the only "better" one is IDEA, but the price for Eclipse is pretty hard to beat. Don't get the MOTIF packages though - at least the GTK version looks like it was built in the last decade. ;)

23rd November 2004, 05:55 AM
Hi All,

thank you all for the help so far, java is executing from the command line correctly after adding the PATH and JAVA_HOME environment variables to 'etc/profile'

however, I am still having the script placeholder execute for javac, please any suggestions how to resolve ?

[root@localhost /]# javac

This script is a placeholder for the /usr/bin/javac
master link required by jpackage.org conventions. libgcj's
rmiregistry, rmic and jar tools are now slave symlinks to these
masters, and are managed by the alternatives(8) system.

This change was necessary because the rmiregistry, rmic and jar tools
installed by previous versions of libgcj conflicted with symlinks
installed by jpackage.org JVM packages.
gcj: no input files

23rd November 2004, 06:05 AM
I just executed this command again, but this time without message:

# alternatives --remove javac /usr/share/java/libgcj-javac-placeholder.sh

# javac
bash: /usr/bin/javac: No such file or directory

Er, yet again any suggestions?

23rd November 2004, 07:29 AM
Try removing GCJ - "rpm -e gcj" should do it.

23rd November 2004, 06:41 PM

Javac is now working, thanks for all the help and advice, talk soon....