Simon Palmer’s blog

June 9, 2013

Upgrading to Java 7 on an Amazon Linux AMI

Filed under: code, Uncategorized — Tags: , — simonpalmer @ 2:37 am

OK, so I’m going to deploy a Play 2 app, backed by MySQL, into AWS.  I am using RDS for the MySQL instance, so I’m not expecting any trouble there, but my code does use Java 1.7, as does my Play 2 framework.

If you use the standard AWS AMI for 64 bit Linux (amzn-ami-pv-2013.03.1.x86_64-ebs (ami-05355a6c)) you will get Java 1.6 by default.  To be fair to Amazon, the AMI does include the Java 1.7 openjdk, but it doesn’t use it by default, you have to upgrade, and here’s how you do that after opening an SSH connection to your running instance:

sudo yum install java-1.7.0-openjdk 

All good so far, but then when I typed java -version it was still using 1.6.  So this is the little nugget I am recording in the hope that it might save you an hour of searching.  

To actually switch to using Java 1.7 you need to use the following:

sudo alternatives --config java

This will show both and you just choose 1.7.  Easy when you know how, impossible when you don’t.

 

Advertisements

7 Comments »

  1. […] the standard Linux AMI at Amazon ships with Java 1.6 as the default, so I had to upgrade that (see here for how to do that). […]

    Pingback by Deploying a Play 2 App to Amazon EC2 connected to RDS | Simon Palmer's blog — June 10, 2013 @ 3:04 am

  2. Thanks for sharing!
    It worked and save me hours of works

    Comment by Joe — September 12, 2013 @ 3:36 am

  3. thanks, worked for me too
    it seems wrong that the default is still 1.6

    Comment by john smithh — October 12, 2013 @ 9:59 pm

  4. THANK YOU!!

    Comment by Anthony — October 18, 2013 @ 9:46 pm

  5. […] to the second error, I found a site (https://simonpalmer.com/2013/06/09/upgrading-to-java-7-on-an-amazon-linux-ami/) describing how to upgrade to Java 7, which followed. Yet I am still getting the […]

    Pingback by neo4j error messages on Amazon EC2 | Stackforum.com — December 31, 2013 @ 5:21 pm

  6. thank you!!!!

    Comment by coder — February 14, 2014 @ 6:06 am

  7. Also for reference, if you require javac compiler you’ll also need to install java-1.7.0-openjdk-devel.x86_64 and then run sudo alternatives –config javac.

    Comment by John Parker — January 12, 2015 @ 1:04 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: