LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 07-11-2011, 05:03 AM   #1
iansu
LQ Newbie
 
Registered: Jul 2011
Posts: 8

Rep: Reputation: Disabled
JDK or JRE problem I don't know really!


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.
 
Old 07-11-2011, 05:13 AM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,688
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Hi,

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...

Thor
 
Old 07-11-2011, 05:31 AM   #3
iansu
LQ Newbie
 
Registered: Jul 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Thor_2.0 View Post
Hi,

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.
 
Old 07-11-2011, 05:34 AM   #4
iansu
LQ Newbie
 
Registered: Jul 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
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.
 
Old 07-11-2011, 06:09 AM   #5
rahulkya
Member
 
Registered: Feb 2009
Location: New Delhi
Distribution: Linux mint,Ubuntu,Debian,RHEL 5,slackware 13.1, free BSD,solaris.
Posts: 186
Blog Entries: 3

Rep: Reputation: 33
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.
 
Old 07-11-2011, 08:03 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156
After installing jdk-1.6.0_26-fcs, you will have to configure the new java.
This is "The Redhat way" : Please do : 1) su

2)
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_26/bin/java 2

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.

..

Last edited by knudfl; 07-11-2011 at 08:11 AM.
 
Old 07-11-2011, 10:32 AM   #7
saiju@wavecrest.gi
LQ Newbie
 
Registered: Jul 2011
Location: India
Distribution: Rhel,CentOS,Ubuntu
Posts: 11

Rep: Reputation: Disabled
Smile

Try this method.... for installing jdk 1.6

1) you should download the jdk rpm like "jdk-6u14-linux-amd64.rpm" for linux x64 bit.


rpm -e --nodeps --allmatches bsh-javadoc-1.3.0-9jpp.1 gcc-java-4.1.2-48.el5 java-1.4.2-gcj-compat-1.4.2.0-40jpp.115 java-1.4.2-gcj-compat-devel-1.4.2.0-40jpp.115 xmlrpc-javadoc-2.0.1-3jpp.1 java-1.4.2-gcj-compat-devel-1.4.2.0-40jpp.115 java-1.4.2-gcj-compat-src-1.4.2.0-40jpp.115 jdk-1.6.0_14-fcs
rpm -ivh jdk-6u14-linux-amd64.rpm
JAVA_HOME="/usr/java/jdk1.6.0_14/"
java -version -server

Let me know if you are facing any more problems with these steps..

Thanks & regds
Saiju
 
Old 07-11-2011, 10:44 AM   #8
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
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.
 
Old 07-12-2011, 05:18 AM   #9
iansu
LQ Newbie
 
Registered: Jul 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
After installing jdk-1.6.0_26-fcs, you will have to configure the new java.
This is "The Redhat way" : Please do : 1) su

2)
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_26/bin/java 2

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.
 
Old 07-12-2011, 08:07 AM   #10
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156
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/ .

Some explanation here .. ( Google : wiki /etc/alternatives )
http://wiki.debian.org/DebianAlternatives

The may be information in the Fedora / Redhat documentation too ?

..

Last edited by knudfl; 07-12-2011 at 08:31 AM.
 
  


Reply

Tags
jdk6


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware64 13.1 packages JRE and JDK conflict? mlpa Slackware 14 08-10-2011 06:48 AM
Java JRE and JDK on CentOs nuttynibbles Linux - Software 1 06-11-2011 02:41 AM
How to install Java jdk and jre in linux BuhRock Linux - Newbie 2 03-27-2011 05:28 PM
Help installing JDK JRE SuSE CS_Student_DrewU Linux - General 2 11-09-2007 09:33 PM
How do I Uninstall Firefox, Jre, jdk, Mozilla TSynergy Linux - Newbie 2 11-18-2004 06:35 PM


All times are GMT -5. The time now is 07:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration