How can I upgrade to Java 1.8 on an Amazon Linux Server?

187,608

Solution 1

To remove java 1.7 and install java 1.8:

sudo yum install java-1.8.0
sudo yum remove java-1.7.0-openjdk

Solution 2

Install Java Runtime 1.8

sudo yum install java-1.8.0

or if you need a java compiler and other developer tools:

sudo yum install java-1.8.0-openjdk-devel

Then use the alternatives command to make Java 1.8 the default.

sudo /usr/sbin/alternatives --config java
sudo /usr/sbin/alternatives --config javac
# etc

If you prefer you can remove Java 1.7 with

sudo yum remove java-1.7.0-openjdk

but remove it after you installed Java 1.8 or the aws-apitools will also be removed as they depend on Java on being installed.

Solution 3

yum install java-1.8.0 -y
/usr/sbin/alternatives --set java /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
/usr/sbin/alternatives --set javac /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/javac
yum remove java-1.7.0-openjdk
Share:
187,608

Related videos on Youtube

K_dar
Author by

K_dar

Updated on September 18, 2022

Comments

  • K_dar
    K_dar over 1 year

    I tried sudo yum update but it just keeps java "1.7.0_75". I need 1.8 for it to work with another application but can't figure out how to upgrade it.
    Do I need to manually install it somehow? There's not much information on this on the internet as far as I can see.
    Specs:

    java version "1.7.0_75"
    OpenJDK Runtime Environment (amzn-2.5.4.0.53.amzn1-x86_64 u75-b13)
    OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
    

    When I try update now:

    [ec2-________]$ sudo yum update
    Loaded plugins: priorities, update-motd, upgrade-helper
    amzn-main/latest                                         | 2.1 kB     00:00
    amzn-updates/latest                                      | 2.3 kB     00:00
    No packages marked for update
    

    Is there anything else I need to do?
    Thanks.

  • K_dar
    K_dar about 9 years
    This is correct, thank you. I'm new to this as you can see.
  • Lionel Port
    Lionel Port about 8 years
    This is the most correct answer. If you follow the accepted answer you will lose aws-apitools.
  • David Levesque
    David Levesque almost 8 years
    Changed the order of installation so that it doesn't remove the aws-apitools.
  • Sanjay Verma
    Sanjay Verma almost 8 years
    +1 for sudo /usr/sbin/alternatives --config java
  • Nokrosis
    Nokrosis over 7 years
    Note this will only install the Java Runtime.
  • orange80
    orange80 almost 7 years
    @johnnieb you can get the full JDK with this: yum install java-1.8.0-openjdk-devel.x86_64
  • Nokrosis
    Nokrosis almost 7 years
    @orange80 I believe the command is yum install java-1.8.0-openjdk-devel -y
  • Mohit Gupta
    Mohit Gupta over 5 years
    @johnnieb the only difference is that your command will make the installer assume yes responses. Not always a good approach.
  • Ankur Srivastava
    Ankur Srivastava over 4 years
    This worked perfectly well for Amazon EC2 Instances and i was looking for that only.
  • ingomueller.net
    ingomueller.net over 3 years
    I have found some other packages to depend on Java 1.7.0 even though they work with Java 1.8.0, so it might be better to keep the original packages installed.