Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I've already posted this kind of thread two times and I still can't find or settle the problem yet.
#[which java] shows this path [/usr/bin/java] which was originally bundled with my red hat enterprise version 5.
#[java -version] shows this :
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20070626 (Red Hat 4.1.2-14)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
First I just think I clearly understand the [java -version] command but now I am not sure it means the jre version or jdk version.Can someone explain to me what does it mean "jre or jdk or both"?
The jdk version which I've installed is rpm version which is jdk-6u26-linux-i586-rpm.bin and installed in the /usr/java/ which is system's automatically selected directory.There is three folder default,jdk1.6.0_26 and latest.
I can prove that I 've successfully installed the jdk by typing this command rpm -qa |grep jdk and it shows this :
jdk-1.6.0_26-fcs
I don't know how to change the java version.
When I typed,#java -version
it should shows java version 1.6.
I would like to use the java 6 version and how to prove my java version is java 6.Help me.Thank you.
RedHat? Okay, try to use galternatives to set the java properly.
By the way, it is perfectly feasable (and workeable, though not very clever/practical) to have more JRE's/JDK's on the same system, as long as the software knows where to find its java. Hence the paths/alternatives.
Quote:
which java
showns the path to the established java on your system. You can change that with galternatives (or, just alternatives if you're okay with the console)
And...this may be a small hit to do some "spring cleaning" on the system...
RedHat? Okay, try to use galternatives to set the java properly.
By the way, it is perfectly feasable (and workeable, though not very clever/practical) to have more JRE's/JDK's on the same system, as long as the software knows where to find its java. Hence the paths/alternatives.
showns the path to the established java on your system. You can change that with galternatives (or, just alternatives if you're okay with the console)
And...this may be a small hit to do some "spring cleaning" on the system...
Thor
When I use the alternative --config java command,the system only knows and shows the java version 1.4 and I don't have other options to select that means the newly installed version 1.6 isn't recognized.
I would like to use one jre and jdk if possible but now the system can't recognize the newly installed version so I can't remove the existing version.If I remove the existing one,there will be no java in my system.
JRE- JRE as the name suggests required to run java files ie "*.class" files or say "*.jar" files . {main executable- /usr/bin/java}
JDK- It is required to create file that can be run on JRE ie "*.java" needs to be compiled with JDK {{main executable- /usr/bin/javac}
I had the same problem . the possible solutions are--
1. install newer version of JDK from yum if its there..
2. move the java and javac files from /usr/bin to home or any other directory which is not included in $PATH.
then make link of javac and java files from the directory /usr/java/ and paste links to /usr/bin then rename them as javac and java rspectively.. this much should be sufficient.
So basically, the problem is that you have java 1.4 installed in /usr/bin/java, and java 1.6 installed in /usr/java. And you want to use the second one.
Whenever you submit a command without a path in front of it, you're searching through the path defined in your own shell. So, you can just modify your shell, and you're set.
You can run the following command at the command line and run your which and java -version commands again, and you should see that you're now using the correct version:
Code:
export PATH=/usr/java:$PATH
Assuming you're using bash, you could add this to your ~/.bashrc file to make it permanent.
3) /usr/sbin/alternatives --config java
.. And select the "sun jdk".
P.S. : There is no reason to remove the gcc-java, gcj:
Other packages may depend on it.
..
Thanks knudfl and all the people who advised me well,I've already overcome the problem with your suggestion,knudfl./usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_26/bin/java 2Can you explain the meaning of the above command to me?And I'd like to know something more clearly,now java -version shows java 1.6,so all my programs compiled and run are using the java,javac of the jdk 1.6(That means usr/java/jdk1.6.0.26/bin and usr/java/jdk1.6.0.26/jre/bin )not /usr/sbin is it right?Thank you all.
Distribution: pclos2010.12, Slack1337 DebSqueeze, +50+ other Linux OS, for test only.
Posts: 9,308
Rep:
Quote:
Can you explain the meaning of the above command to me
The "alternatives --install" command is simply installing links into /etc/alternatives/.
When applications are installed in more than one version, you can then select
the one, that is to be the "default version" / default application.
Some packages are installing alternatives/<link> automatically at package install.
Please have a look for yourself, in your file browser, or with the command :
ls -l /etc/alternatives/ .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.