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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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:
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
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)
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!
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.