LinuxQuestions.org
Help answer threads with 0 replies.
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 05-30-2008, 10:56 AM   #1
Yig
Member
 
Registered: Aug 2005
Location: Montreal, Qc
Distribution: CentOs 4.5/5.0
Posts: 113

Rep: Reputation: 15
Changing default version of Java?


Hi,

I just installed the latest JDK RPM on my machine (CentOS 5) but Java 1.4.2 is still the default version. I tested running java -version and got 1.4.2.

What do I need to change so that 1.6 is the new default?

Thanks!
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-30-2008, 11:41 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,948

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by Yig View Post
Hi,

I just installed the latest JDK RPM on my machine (CentOS 5) but Java 1.4.2 is still the default version. I tested running java -version and got 1.4.2.

What do I need to change so that 1.6 is the new default?

Thanks!
Check the symbolic link for your java directory. Look at the docs, but doing a "which java" at the command line will give you a good start. The /usr/java directory (at least on my system), goes to /usr/java-1.6.xx/whatever. If I upgrade, and the next version goes into /usr/java-1.99/whatever, I just move the symbolic link.
 
Old 05-30-2008, 12:42 PM   #3
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 61
Is the "alternatives" system something that is Debian-only?

In Debian...
# update-alternatives --config java
...fixes it in a flash.
 
Old 05-30-2008, 01:28 PM   #4
Yig
Member
 
Registered: Aug 2005
Location: Montreal, Qc
Distribution: CentOs 4.5/5.0
Posts: 113

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by TB0ne View Post
Check the symbolic link for your java directory. Look at the docs, but doing a "which java" at the command line will give you a good start. The /usr/java directory (at least on my system), goes to /usr/java-1.6.xx/whatever. If I upgrade, and the next version goes into /usr/java-1.99/whatever, I just move the symbolic link.
Let me see...

which java returned

/usr/bin/java


And that file is question is java -> /etc/alternatives/java

The RPM was installed in /usr/java. And I see the following in that directory:

default -> /usr/java/latest
jdk1.6.0_06
latest -> /usr/java/jdk1.6.0_06

The actual java command is in /usr/java/jdk1.6.0_06/jre/bin so how do I change the link to it?
 
Old 02-13-2012, 06:11 PM   #5
mnabil
LQ Newbie
 
Registered: Feb 2012
Location: Casablanca
Distribution: CentOS release 5.7 (Final)
Posts: 1

Rep: Reputation: Disabled
Just in case someone needs this...

in /etc/alternatives folder modify the java link to the following (adapt to your java folder location)
sudo ln -T /usr/java/jdk1.7.0/bin/java java
nothing to do in /usr/bin
 
Old 02-23-2012, 12:23 PM   #6
Fivalo
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Rep: Reputation: Disabled
Error changing the link

Hi

I have changed the link /etc/aternatives/java to the bin directory to the Sunīs Virtual Machine, and Iīm having this error when I type java -version :


[root@mn alternatives]# java -version
java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

Anybody has an idea what is wrong

Thanks
 
Old 02-23-2012, 01:03 PM   #7
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
You should open a new thread & tell us what distro & how you installed.
 
Old 02-23-2012, 01:26 PM   #8
Fivalo
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Rep: Reputation: Disabled
Resolved

Hi

I have found the solution, that is the following:


Chose an installation destination directory. Create the parent directory, if necessary, and change into it.
# mkdir -p /opt && cd /opt
Obtain the insanely large shell package from SUN. Pay close attention to 32/64 bit. You do not want the version with rpm in the file name. Typically, you want the 64-bit version these days. Save it in a location so you can access it in the next step.
Run the shell expander. Follow its prompts
# /bin/sh /path/to/jdk-6u20-linux-x64.bin
Run the alternatives program to tell the system about the existence of your new installation:
# alternatives --install /usr/bin/java java /opt/jdk1.6.0_20/bin/java 2
Run the alternatives program again, to chose the new installation
# alternatives --config java
Verify that you are getting the right version of Java
$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)


Thanks
 
2 members found this post helpful.
Old 02-23-2012, 01:31 PM   #9
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
The new version of java is 1.7.0, so if you use google chrome 1.6.0 will not work
 
Old 04-05-2012, 11:26 PM   #10
sumitkm
LQ Newbie
 
Registered: Apr 2012
Posts: 1

Rep: Reputation: Disabled
Thumbs up Worked like a charm

Quote:
Originally Posted by Fivalo View Post
Hi

I have found the solution, that is the following:


Chose an installation destination directory. Create the parent directory, if necessary, and change into it.
# mkdir -p /opt && cd /opt
Obtain the insanely large shell package from SUN. Pay close attention to 32/64 bit. You do not want the version with rpm in the file name. Typically, you want the 64-bit version these days. Save it in a location so you can access it in the next step.
Run the shell expander. Follow its prompts
# /bin/sh /path/to/jdk-6u20-linux-x64.bin
Run the alternatives program to tell the system about the existence of your new installation:
# alternatives --install /usr/bin/java java /opt/jdk1.6.0_20/bin/java 2
Run the alternatives program again, to chose the new installation
# alternatives --config java
Verify that you are getting the right version of Java
$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)


Thanks
Thanks a ton , worked like a charm on RHEL 5.
I had three java installations and on the last step

alternatives --config java

I was asked to pick the number.

For a Linux noob like me, your steps were a big help!
 
Old 12-15-2012, 12:08 PM   #11
Geremia
Member
 
Registered: Apr 2011
Distribution: slackware64-current
Posts: 331

Rep: Reputation: 35
$java_home

Can't one just set the JAVA_HOME environment variable?
 
Old 12-15-2012, 02:29 PM   #12
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 2,326
Blog Entries: 1

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
You can set LD_LIBRARY_PATH before running an application that uses java. I just added the path to a custom .conf file in /etc/ld.so.conf.d/ and ran ldconfig. Although more or less for the browser plugin that doesn't use openGL if you don't tell java where java is located. And LD is more for the libraries and not the applications. And then there's the pulseaudio issue where you have to pretty much install and configure pulseaudio to use the supplied distro package without audio related quirks.
 
  


Reply


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
Changing default font in Java mmarkvillanueva Linux - Software 2 07-28-2014 05:06 PM
java -version, bash: java: command not found kirman Programming 4 03-20-2008 12:13 AM
How to set the default Java version robbbert Linux - Software 4 03-20-2006 03:44 PM
Changing Default Route civicsi Linux - Newbie 1 04-23-2004 02:15 PM
changing default WM pmh6310 Linux - Newbie 5 06-11-2003 06:00 PM


All times are GMT -5. The time now is 02:32 PM.

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