Java – How to switch java versions to an earlier version in Fedora 17

fedorajava

I just installed Fedora 17. I'm setting up the Android Build Environment and need Java.

I downloaded and installed jdk-6u32-linux-amd64.rpm I ran

java -version

and it spit out the correct version.

Well a day or two later i tried my first compile in Fedora 17 and it complained about java and failed. I ran java -version again and low and behold it spits out

$ java -version
java version "1.7.0_03-icedtea"
OpenJDK Runtime Environment (fedora-2.1.fc17.7-x86_64)
OpenJDK 64-Bit Server VM (build 22.0-b10, mixed mode)

I'm stumped. I mean, i've run the update/upgrade commands since i installed but i didn't think that updated full version revisions…
So, I ran

alternatives --config java

and that only gave me the java 1.7 version.

While digging around more I discovered that the recommended version of Java for the build environment is jdk-6u27-linux-x64-rpm.bin so I downloaded that from here: Oracle Download

When I ran:

sudo sh jdk-6u27-linux-x64-rpm.bin

it returned:

Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
  inflating: jdk-6u27-linux-amd64.rpm  
  inflating: sun-javadb-common-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-core-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-client-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm  
Preparing...                ########################################### [100%]
    package jdk-2000:1.6.0_32-fcs.x86_64 (which is newer than jdk-2000:1.6.0_27-fcs.x86_64) is already installed

Done.

so now I'm confused. I ran:

alternatives --config java

again but it's still only returning 1.7 so I don't know what to do.I want to end up with 6u27 as the installed and functional version of the JDK. Thank you.

Best Answer

After you unpack the linux bin, You have to let system know.

alternatives --install /usr/bin/java java /path/to/your/java 10

then you can config it with

alternatives --config java