Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch to JDK 7 in Amazon Linux

I have t1.micro 64-bit instance, where I installed JDK 7 following some instructions (sudo yum install java-1.7.0-openjdk-devel)(sudo yum update etc). So, when I search for it,

sudo yum search openjdk

I get following-

java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle

So, both are installed. But when I try to switch to JDK 7 using

sudo update-alternatives --config java 

I get-

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

Why is it showing only the 6?

I tried other commands like-

sudo update-alternatives --set javac /usr/lib/jvm/java-7-openjdk/bin/javac

but no success.

like image 383
Naman Avatar asked Nov 20 '13 22:11

Naman


1 Answers

To ensure that openjdk 7 is installed, run below command.

# rpm -qa | grep openjdk

It should list 1.6 and 1.7 if you have both installed. If it lists only 1.6 (as in your case I would guess), then sudo update-alternatives --config java is working fine and you need to install jdk 7 by running yum -y install java-1.7.0-openjdk

Here is the output from my machine:

# rpm -qa | grep openjdk
java-1.7.0-openjdk-1.7.0.45-2.4.3.2.32.amzn1.x86_64
java-1.6.0-openjdk-1.6.0.0-65.1.11.14.57.amzn1.x86_64

# update-alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number:
like image 190
slayedbylucifer Avatar answered Oct 17 '22 15:10

slayedbylucifer