How to Upgrade Oracle Java on Ubuntu Linux

Method 1 of 4:

32-bit Oracle Java instructions:

  1. How to Upgrade Oracle Java on Ubuntu Linux Picture 1
    Become root user and copy the new compressed Oracle Java binaries from our download directory to /usr/local/java
    1. Type/Copy/Paste: cd /home/"your_user_name"/Downloads
    2. Type/Copy/Paste: sudo cp -r jdk-7u40-linux-i586.tar.gz /usr/local/java
    3. Type/Copy/Paste: sudo cp -r jre-7u40-linux-i586.tar.gz /usr/local/java
    4. Type/Copy/Paste: cd /usr/local/java
  2. How to Upgrade Oracle Java on Ubuntu Linux Picture 2
    Next we are going to unpack our new version of Oracle Java binaries, in the directory /usr/local/java
    1. Type/Copy/Paste: sudo tar xvzf jdk-7u40-linux-i586.tar.gz
    2. Type/Copy/Paste: sudo tar xvzf jre-7u40-linux-i586.tar.gz
Method 2 of 4:

64-bit Oracle Java instructions:

  1. How to Upgrade Oracle Java on Ubuntu Linux Picture 3
    Become root user and copy the new compressed Oracle Java binaries from our download directory to /usr/local/java
    1. Type/Copy/Paste: cd /home/"your_user_name"/Downloads
    2. Type/Copy/Paste: sudo -s cp -r jdk-7u40-linux-x64.tar.gz /usr/local/java
    3. Type/Copy/Paste: sudo -s cp -r jre-7u40-linux-x64.tar.gz /usr/local/java
    4. Type/Copy/Paste: cd /usr/local/java
  2. How to Upgrade Oracle Java on Ubuntu Linux Picture 4
    Next we are going to unpack our new version of Oracle Java binaries, in the directory /usr/local/java
    1. Type/Copy/Paste: sudo tar xvzf jdk-7u40-linux-x64.tar.gz
    2. Type/Copy/Paste: sudo tar xvzf jre-7u40-linux-x64.tar.gz
  3. How to Upgrade Oracle Java on Ubuntu Linux Picture 5
    At this point you should have two new uncompressed binary directories in /usr/local/java for the Java JDK/JRE listed as:

    jdk1.7.0_40
    jre1.7.0_40

    Along with:

    jdk1.7.0_25
    jre1.7.0_25
Method 3 of 4:

Modify your Linux system PATH:

  1. How to Upgrade Oracle Java on Ubuntu Linux Picture 6
    Edit the system PATH file /etc/profile and add the following system variables to your system path. Use gedit, nano or any other text editor, as root, and open up /etc/profile
    1. Type/Copy/Paste: sudo gedit /etc/profile
      or
    2. Type/Copy/Paste: sudo nano /etc/profile
  2. How to Upgrade Oracle Java on Ubuntu Linux Picture 7
    Scroll down using your arrow keys to the end of the file and add the following lines below to the end of your /etc/profile file in Ubuntu Linux,at this point you are going to be changing the version numbers from the old Oracle Java to the new version of Java, you will change the versions numbers in the following system PATH file /etc/profile:

    Modify the /etc/profile file:
    JAVA_HOME=/usr/local/java/jdk1.7.0_25
    PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
    JRE_HOME=/usr/local/java/jre1.7.0_25
    PATH=$PATH:$HOME/bin:$JRE_HOME/bin
    export JAVA_HOME
    export JRE_HOME
    export PATH

    Change to this:
    JAVA_HOME=/usr/local/java/jdk1.7.0_40
    PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
    JRE_HOME=/usr/local/java/jre1.7.0_40
    PATH=$PATH:$HOME/bin:$JRE_HOME/bin
    export JAVA_HOME
    export JRE_HOME
    export PATH

    Save the file and exit
Method 4 of 4:

Inform your system of the updated Oracle Java version:

  1. How to Upgrade Oracle Java on Ubuntu Linux Picture 8
    Inform your Ubuntu Linux system where your Oracle Java JRE/JDK is located, now you will want to update the system to use Oracle Java 1.7.0_40
    1. Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_40/bin/java" 1
    2. Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_40/bin/javac" 1
    3. Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0_40/bin/javaws" 1
  2. How to Upgrade Oracle Java on Ubuntu Linux Picture 9
    Inform your Ubuntu Linux system, that Oracle Java JRE 1.7.0_40 must be the new default Java
    1. Type/Copy/Paste: sudo update-alternatives --set java /usr/local/java/jre1.7.0_40/bin/java
    2. Type/Copy/Paste: sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_40/bin/javac
    3. Type/Copy/Paste: sudo update-alternatives --set javaws /usr/local/java/jre1.7.0_40/bin/javaws
  3. How to Upgrade Oracle Java on Ubuntu Linux Picture 10
    Reload your system wide PATH /etc/profile by typing the following command:
    1. Type/Copy/Paste: . /etc/profile
    2. Note your system wide PATH /etc/profile file will reload after reboot of your Ubuntu Linux system
  4. How to Upgrade Oracle Java on Ubuntu Linux Picture 11
    Test to see if the new version of Oracle Java was installed correctly on your system by running the following commands and noting the version number of the new Java update.
    1. Type/Copy/Paste: java -version
      1. this command displays the version of Java running on your system
  5. How to Upgrade Oracle Java on Ubuntu Linux Picture 12
    You should receive a message which displays:
    1. java version "1.7.0_40"

      Java(TM) SE Runtime Environment (build 1.7.0_40-b08)Java HotSpot(TM) 64-Bit Server VM (build build 25.1-b02, mixed mode)
    2. Type/Copy/Paste: javac -version
    3. this command lets you know that you are now able to compile java programs from the terminal
      1. You should receive a message which displays:
    4. javac 1.7.0_40
  6. How to Upgrade Oracle Java on Ubuntu Linux Picture 13
    Afterwards, you have the option of removing the old Oracle Java JDK/JRE, by simply removing the directory's which hold the old Java JDK/JRE binaries.
    1. Type/Copy/Paste: cd /usr/local/java
    2. Type/Copy/Paste: sudo rm -rf jdk1.7.0_40
    3. Type/Copy/Paste: sudo rm -rf jre1.7.0_40
  7. How to Upgrade Oracle Java on Ubuntu Linux Picture 14
    Reboot your Ubuntu Linux system and your system will be fully configured for running and developing Java programs.
3.9 ★ | 18 Vote

May be interested

  • How to install Java on a Raspberry PiHow to install Java on a Raspberry Pi
    there are two different java implementations, oracle java and openjdk. this tutorial explains how to install java (openjdk) on a raspberry pi with the latest raspbian operating system running on it.
  • How to Install Java on LinuxHow to Install Java on Linux
    this wikihow teaches you how to install the latest version of the java runtime environment (jre) on a computer running linux. open the [https://www.java.com/en/download/linux_manual.jsp java for linux download page]. you'll see several...
  • 8 ways Ubuntu changes and improves Linux8 ways Ubuntu changes and improves Linux
    ubuntu is the most prominent linux distribution in the world. ubuntu and its developer, canonical, have been plagued by a lot of fuss over the years, but the linux world is getting much better thanks to both.
  • Tips and tricks after installing UbuntuTips and tricks after installing Ubuntu
    ubuntu is one of the completely free open source operating systems. this is a distribution (distro) of linux with the second highest amount of traffic after linux mint.
  • 12 best Linux server operating systems12 best Linux server operating systems
    although linux operating systems provide a great desktop environment, linux can also successfully complete the task of a server. linux often provides advanced permissions, increasing flexibility and stability.
  • 7 Enterprise Linux Server Distributions7 Enterprise Linux Server Distributions
    the newest entrants to the linux team are businesses looking for stable and secure distributions to enhance their production cycles.
  • How to Install the Java Software Development KitHow to Install the Java Software Development Kit
    before you can create and modify java programs, you'll need the java software development kit. you can download the kit (also known as java sdk or jdk) for free from oracle as a single installer file, which makes installation quick and...
  • 5 things to do after upgrading to Ubuntu 22.04 LTS5 things to do after upgrading to Ubuntu 22.04 LTS
    ubuntu 22.04 lts jammy jellyfish is the latest version of the popular open source operating system ubuntu. installing a fresh copy on a freshly wiped hard drive will give you a great computing experience.
  • How to Upgrade UbuntuHow to Upgrade Ubuntu
    if you use the ubuntu operating system, upgrading to the newest version will give you access to the latest features and optimizations. the upgrade process in ubuntu is very straightforward, but there are a few things you can do before you...
  • Is Arch Linux better than Ubuntu?Is Arch Linux better than Ubuntu?
    arch linux and ubuntu are two big names in the linux world. both have a huge fan base, with two completely opposite positions.