Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 21st July 2005, 08:28 PM
mrmcd Offline
Registered User
 
Join Date: Mar 2005
Posts: 34
java gurus? yet another java sdk 1.5 question

Ok, so I installed this machine with the latest ISO's for FC3 about a month ago...There appears to be java 1.4.2 already installed on it. I need Java SDK 1.5, so I installed that with the instructions on one of the HOWTO threads:
http://forums.fedoraforum.org/showth...light=java+1.5

Everything seemed to install alright, but if I type "$ java -version" in shell I get:
Code:
[...]$ java -version
java version "1.4.2"
jdkgcj 0.3.1 (http://www.arklinux.org/projects/jdkgcj)
gcj (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.fc3)
Copyright (C) 2004 Free Software Foundation, Inc.
...
I'm guessing the problem is there are two different java installations on this machine now...can I set it up so the correct version 1.5 gets used when I type "java ...", "javac ...", etc.?

Thanks in advance for any help, I can't remember how to do this.
(Please keep in mind I followed the instructions on that HOWTO page precisely, including the symlink. Last time I had to do something like this there were a lot of symlinks pointing to all the wrong places...a real mess).

Last edited by mrmcd; 21st July 2005 at 08:31 PM.
Reply With Quote
  #2  
Old 21st July 2005, 08:35 PM
Furball's Avatar
Furball Offline
Registered User
 
Join Date: Jul 2005
Location: Passau, Germany
Age: 33
Posts: 331
You can see which executables are available with
Code:
type -a java
# example output: 
java is /public/jdk1.5.0_03-64bit/bin/java
java is /usr/bin/java
to use a specific one it must be the first in the PATH variable. Have a look at it with 'echo $PATH'
Now prepend the java of your choice to this path:
for example:
Code:
export PATH=/path/to/my/java/bin:$PATH
type -a java should print now your favorite java at the top (the fist one is used)
__________________

Benjamin Duehring, FORWISS
Universitaet Passau, D-94030 Passau
WWW: http://www.lyxx.de/card
Reply With Quote
  #3  
Old 21st July 2005, 09:44 PM
dwflo's Avatar
dwflo Offline
Registered User
 
Join Date: Jun 2005
Location: Albuquerque
Age: 64
Posts: 409
@ Furball, I have someting to add.
My Java installation is different than what you indicate.
According to the Java website install instructions, they differ with the "Howto" in thread http://forums.fedoraforum.org/showth...light=java+1.5.
I followed the Java install, do not have a /usr/local/java. My installation is on the x86_64 platform, so it may be the setup is different. Also hav gcj 1.4.2, if that makes any difference.
If I enter "java" in the terminal, I get "gij". Don't know if it is a good idea to gcj installed! Could it mess up ny "real java" $PATH?
I do have problems with java apps running on my system, can't find paths, even after evoking the export command! What is my problem, read all the documentation, but I am lost.

Dave
__________________
Registered Linux #395226 running Fedora 7 x86_64
"Three men were walking on a wall, Feeling, Faith and Fact.
Feeling took an awful fall and Faith was taken back.
But Fact remained both strong and true and that brought back Faith and Feeling too!"
Reply With Quote
  #4  
Old 21st July 2005, 11:05 PM
smfinley's Avatar
smfinley Offline
Retired Community Manager
 
Join Date: Jul 2004
Posts: 1,335
Use the alternatives system. See the Java sections in the FC3 Notes and the FC4 Notes for examples.
__________________
Stanton Finley
stanton-finley.net
Reply With Quote
  #5  
Old 22nd July 2005, 10:32 PM
ulasergin Offline
Registered User
 
Join Date: Jun 2005
Location: Istanbul
Age: 34
Posts: 29
I have both 1.4.2 and 1.5.0 installed.
I wrote java.sh in /etc/profile.d directory with the contents below
#export JAVA_HOME=/opt/j2sdk1.4.2_08
export JAVA_HOME=/opt/jdk1.5.0_04
export PATH=$JAVA_HOME/bin:$PATH

where /opt/jdkxxx is my java installation root.

so java -version gives 1.5 now

hope this helps
Reply With Quote
  #6  
Old 23rd July 2005, 03:49 AM
dwflo's Avatar
dwflo Offline
Registered User
 
Join Date: Jun 2005
Location: Albuquerque
Age: 64
Posts: 409
Quote:
Originally Posted by ulasergin
I have both 1.4.2 and 1.5.0 installed.
I wrote java.sh in /etc/profile.d directory with the contents below
#export JAVA_HOME=/opt/j2sdk1.4.2_08
export JAVA_HOME=/opt/jdk1.5.0_04
export PATH=$JAVA_HOME/bin:$PATH

where /opt/jdkxxx is my java installation root.

so java -version gives 1.5 now

hope this helps
Did that but it did not work, I think it has to do with gcj. Keeps pointing to java 1.4.2.
I will figure it out, not giving up, even if I must remove gcj.

Dave
__________________
Registered Linux #395226 running Fedora 7 x86_64
"Three men were walking on a wall, Feeling, Faith and Fact.
Feeling took an awful fall and Faith was taken back.
But Fact remained both strong and true and that brought back Faith and Feeling too!"
Reply With Quote
  #7  
Old 23rd July 2005, 12:18 PM
ulasergin Offline
Registered User
 
Join Date: Jun 2005
Location: Istanbul
Age: 34
Posts: 29
I don't understand why it does not work. If you add 1.5 to the beginning of $PATH then shell should locate if first,
anyway you should try another 'shortcut' : add an 'alias' to /opt/java1.5 as java to your .bashrc

alias java='/opt/java1.5xyz ' should work
Reply With Quote
  #8  
Old 23rd July 2005, 05:10 PM
mrmcd Offline
Registered User
 
Join Date: Mar 2005
Posts: 34
This was a symlink issue for me. When you use "type -a java" or "whereis java" you're going to see the locations of all your java installations. My Java 1.5 installation was in "/usr/local/java/" but that's going to be different for other users. If you don't know which one is your java 1.5 install, dig around the folders and subfolders that "type" and "whereis" reported and you'll eventually see "1.5" or "1.4.2" in one of the file names. Once you have found your 1.5 install, you need to make a symlink to the binary executable in it. This is going to exist in a folder called "bin" and the executable file is going to be called "java" (executables are green in a default shell.) My java 1.5 executable was /usr/local/java/bin/java .

In my case there was a symlink to the 1.4.2 install already, and this is what the $PATH stuff was actually seeing. The symlink file was "/usr/bin/java" ... open the file "/usr/bin/java" with a text editor and a few lines down you will see the version it is pointing too... in my case it said " echo 'java version "1.4.2"' 1>&2 " on line 15 . That is definetly not pointing to my java 1.5 installation. So I changed to root, removed the symlink (rm /usr/bin/java ... you might want to make a backup) and then made a new symlink to my java 1.5 installation:

ln -s /usr/local/java/bin/java /usr/bin/java
(ln -s /your/new/java/directory/bin/java /usr/bin/java)
Then after typing "java -version" I saw that it was linking to right java installation.

There are a couple things about this. First, this worked on my FC3 installs, I am not running FC4 yet. Secondly, if you ever need to install new versions of java or want to revert back to an old one, you will have to do this process. The symlink in /usr/bin/java will have to point to one of the multiple java installations you put anywhere on your computer. This is the same process, just remove the /usr/bin/java symlink and make a new one with
ln -s /new/java/installation/bin/java /usr/bin/java
where /new/java/installation is not literal, but the location of your new java installation.
Reply With Quote
  #9  
Old 24th July 2005, 09:03 PM
dwflo's Avatar
dwflo Offline
Registered User
 
Join Date: Jun 2005
Location: Albuquerque
Age: 64
Posts: 409
Greetings all,
Got it fixed, took some work, but able to get problems resolved. Had to step back, cool down and research, mission accomplished.
Thanks for all your help, made it easier to figure it out. Just hope I can remember the fixes next time.

Dave
__________________
Registered Linux #395226 running Fedora 7 x86_64
"Three men were walking on a wall, Feeling, Faith and Fact.
Feeling took an awful fall and Faith was taken back.
But Fact remained both strong and true and that brought back Faith and Feeling too!"
Reply With Quote
  #10  
Old 24th July 2005, 11:08 PM
dwflo's Avatar
dwflo Offline
Registered User
 
Join Date: Jun 2005
Location: Albuquerque
Age: 64
Posts: 409
I do have one question.
Ater exporting my java path, in user mode, it does not remain after I exit the terminal!
How to I make it perminant?

Dave
__________________
Registered Linux #395226 running Fedora 7 x86_64
"Three men were walking on a wall, Feeling, Faith and Fact.
Feeling took an awful fall and Faith was taken back.
But Fact remained both strong and true and that brought back Faith and Feeling too!"
Reply With Quote
  #11  
Old 25th July 2005, 03:07 AM
Omega Blue's Avatar
Omega Blue Offline
Registered User
 
Join Date: Apr 2005
Location: Fragrant Harbour
Posts: 1,344
Put the export line in your bash profile. It is .bash_profile in your home directory.
Reply With Quote
  #12  
Old 25th July 2005, 04:04 AM
crackers's Avatar
crackers Offline
Retired Community Manager
 
Join Date: Feb 2004
Location: Seattle, WA, USA
Age: 56
Posts: 3,423
It is generally considered "bad practice" to explicitly set the $CLASSPATH variable as a "permanent" environment setting. This can cause untold heart-ache and grief when you're trying to execute something and a completely different Class is loaded than what you would expect (because you previously included it on the $CLASSPATH).

The typical approach is to use the -cp command-line argument, usually in a shell-script. FYI, I've never had to set the $CLASSPATH variable since JDK 1.2 except as a "local" (terminal session) short-cut.
__________________
Linux User #28251 (April '93)
Professional Java Geek :cool:
Reply With Quote
  #13  
Old 25th July 2005, 04:27 AM
cayhorstmann Offline
Registered User
 
Join Date: Jun 2005
Posts: 12
Quote:
Originally Posted by crackers
It is generally considered "bad practice" to explicitly set the $CLASSPATH variable as a "permanent" environment setting. This can cause untold heart-ache and grief when you're trying to execute something and a completely different Class is loaded than what you would expect (because you previously included it on the $CLASSPATH).

The typical approach is to use the -cp command-line argument, usually in a shell-script. FYI, I've never had to set the $CLASSPATH variable since JDK 1.2 except as a "local" (terminal session) short-cut.
I wholehearteldy agree with this, but let's not confuse the issues. The issue at hand was to set the PATH, not CLASSPATH. I do think it makes sense to put one's preferred Java installation on the global PATH (e.g. in .bash_profile).
Reply With Quote
Reply

Tags
gurus, java, question, sdk

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lousy Java script or dated Java? Clean Mind Using Fedora 3 4th January 2009 04:30 AM
[F9 64-bit] jperf Java f/e for iperf - Java exception error techmum Using Fedora 0 24th July 2008 01:22 AM
Can I update java by simply installing java? schwim Using Fedora 5 20th December 2007 01:34 PM
Java Question miller0521 Using Fedora 23 4th December 2006 12:30 AM
java prob: alternatives --config java peimankhosravi Using Fedora 0 12th August 2005 04:06 PM


Current GMT-time: 13:04 (Monday, 20-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat