Replace openjdk with oracle-jdk on Ubuntu












50















I have an ubuntu system and I want to replace my openjdk with oracle-jdk.



However if I remove my open-jdk and then install oracle-jdk, when I try to install some packages they want to install openjdk and I don't want this.



Is there any way to install those packages on top of oracle-jdk? One of those packages is freemind.










share|improve this question















migrated from stackoverflow.com Mar 6 '14 at 17:22


This question came from our site for professional and enthusiast programmers.



















  • Which packages require open-jdk that you want to install? (besides freemind)

    – Seth
    Mar 6 '14 at 17:24













  • I caught oracle-jdk adding itself to PATH in /etc/profile.d/jdk.sh. Removing this file and starting a fresh shell allowed update-alternatives to do its job.

    – jozxyqk
    Mar 14 '17 at 22:48
















50















I have an ubuntu system and I want to replace my openjdk with oracle-jdk.



However if I remove my open-jdk and then install oracle-jdk, when I try to install some packages they want to install openjdk and I don't want this.



Is there any way to install those packages on top of oracle-jdk? One of those packages is freemind.










share|improve this question















migrated from stackoverflow.com Mar 6 '14 at 17:22


This question came from our site for professional and enthusiast programmers.



















  • Which packages require open-jdk that you want to install? (besides freemind)

    – Seth
    Mar 6 '14 at 17:24













  • I caught oracle-jdk adding itself to PATH in /etc/profile.d/jdk.sh. Removing this file and starting a fresh shell allowed update-alternatives to do its job.

    – jozxyqk
    Mar 14 '17 at 22:48














50












50








50


43






I have an ubuntu system and I want to replace my openjdk with oracle-jdk.



However if I remove my open-jdk and then install oracle-jdk, when I try to install some packages they want to install openjdk and I don't want this.



Is there any way to install those packages on top of oracle-jdk? One of those packages is freemind.










share|improve this question
















I have an ubuntu system and I want to replace my openjdk with oracle-jdk.



However if I remove my open-jdk and then install oracle-jdk, when I try to install some packages they want to install openjdk and I don't want this.



Is there any way to install those packages on top of oracle-jdk? One of those packages is freemind.







java dependencies openjdk






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 '14 at 17:26









Seth

34.9k27112165




34.9k27112165










asked Mar 6 '14 at 11:22









little alilittle ali

362148




362148




migrated from stackoverflow.com Mar 6 '14 at 17:22


This question came from our site for professional and enthusiast programmers.









migrated from stackoverflow.com Mar 6 '14 at 17:22


This question came from our site for professional and enthusiast programmers.















  • Which packages require open-jdk that you want to install? (besides freemind)

    – Seth
    Mar 6 '14 at 17:24













  • I caught oracle-jdk adding itself to PATH in /etc/profile.d/jdk.sh. Removing this file and starting a fresh shell allowed update-alternatives to do its job.

    – jozxyqk
    Mar 14 '17 at 22:48



















  • Which packages require open-jdk that you want to install? (besides freemind)

    – Seth
    Mar 6 '14 at 17:24













  • I caught oracle-jdk adding itself to PATH in /etc/profile.d/jdk.sh. Removing this file and starting a fresh shell allowed update-alternatives to do its job.

    – jozxyqk
    Mar 14 '17 at 22:48

















Which packages require open-jdk that you want to install? (besides freemind)

– Seth
Mar 6 '14 at 17:24







Which packages require open-jdk that you want to install? (besides freemind)

– Seth
Mar 6 '14 at 17:24















I caught oracle-jdk adding itself to PATH in /etc/profile.d/jdk.sh. Removing this file and starting a fresh shell allowed update-alternatives to do its job.

– jozxyqk
Mar 14 '17 at 22:48





I caught oracle-jdk adding itself to PATH in /etc/profile.d/jdk.sh. Removing this file and starting a fresh shell allowed update-alternatives to do its job.

– jozxyqk
Mar 14 '17 at 22:48










4 Answers
4






active

oldest

votes


















78














You can completely remove the OpenJDK and fresh Install Oracle Java JDK by following these steps:





  1. Remove OpenJDK completely by this command:



    sudo apt-get purge openjdk-*



  2. Download the Oracle Java JDK here.



    Note: download appropriate file, for example if your system is x64 Ubuntu (i.e, Debian) the download file is named like this: jdk-8u51-linux-x64.tar.gz



    To find which version is your OS, check here




  3. Create a folder named java in /usr/local/by this command:



    sudo mkdir -p /usr/local/java



  4. Copy the Downloaded file in the directory /usr/local/java. To do this, cd into directory where downloaded file is located and use this command for copying that file to /usr/local/java/:



    sudo cp -r jdk-8u51-linux-x64.tar.gz /usr/local/java/



  5. CD into /usr/local/java/ directory and extract that copied file by using this command:



    sudo tar xvzf jdk-8u51-linux-x64.tar.gz


  6. After extraction you must see a folder named jdk1.8.0_51.



  7. Update PATH file by opening /etc/profile file by the command sudo nano /etc/profile and paste the following at the end of the file:



    JAVA_HOME=/usr/local/java/jdk1.8.0_51
    PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
    export JAVA_HOME
    export PATH


  8. Save and exit.



  9. Tell the system that the new Oracle Java version is available by the following commands:



    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_51/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_51/bin/javac" 1
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_51/bin/javaws" 1



  10. Make Oracle Java JDK as default by this following commands:



    sudo update-alternatives --set java /usr/local/java/jdk1.8.0_51/bin/java
    sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_51/bin/javac
    sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_51/bin/javaws



  11. Reload sytem wide PATH /etc/profile by this command:



    source /etc/profile


  12. Reboot your system.



  13. Check Java JDK version by java -version command . If installation is succesful, it will display like the following:



    java version "1.8.0_51"
    Java(TM) SE Runtime Environment (build 1.8.0_51-xxx)
    Java HotSpot(TM) Server VM (build 25.51-xxx, mixed mode)



That's it!



Note: We Assumed that the downloaded file is named jdk-8u51-linux-x64.tar.gz and used this name in all the commands used in steps 2, 4 and 5. It may depends on the type of O.S, processor type (i.e., 32bit or 64bit)






share|improve this answer





















  • 1





    Beside this is the correct way to manually install oracle-jdk there is a package available from WebUpd8 PPA which will be updated, too. So there is no need to install every new version manually. See my answer here: askubuntu.com/questions/466166/…

    – lschuetze
    Apr 1 '15 at 9:21






  • 2





    Instead of using the directory jdk1.8.0_51, create a symlink named just "jdk" to this directory and next time you update just extract the JDK tarball and recreate the symlink and you're done.

    – ColinM
    Aug 4 '15 at 18:37











  • for ubuntu users: theres a foolproof method below from @mihaic that works well for me

    – Carson Ip
    Dec 26 '15 at 8:30













  • You are rockstar

    – Bhupinder
    Dec 14 '16 at 15:09











  • Please note that if you want to download the JDK in Ubuntu Server (without GUI), you can use the following command: wget --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz" You can always copied the latest version by go back the Oracle download page and generate a new one.

    – Toan Nguyen
    Feb 22 '18 at 4:40



















20














You don't need to remove openjdk in order to use / install the oracle's jdk. Just install the oracle's jdk and configure which java you want to use by configuring it with:



sudo update-alternatives --config java


You can find more help here: https://help.ubuntu.com/community/Java






share|improve this answer


























  • I need a way to have only one java on my ubuntu. tnx.

    – little ali
    Mar 6 '14 at 11:48











  • This is a great answer. Groovy on Debian jessie forces openjdk to be installed, but the work I do requires (don't ask) the Oracle JDK for compilation. This option allowed me to leave both openjdk and oracle jdk installed so everything plays nicely. Thanks!

    – sanimalp
    Sep 8 '16 at 17:03











  • Perfect answer.. Thanks for this..:)

    – john400
    Sep 2 '17 at 3:07



















11














Tested in Ubuntu 14.04/16.04. In three steps:





  1. Install the oracle-java7-installer (or oracle-java8-installer) from the webupd8team repository



    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer



  2. Make sure it works with the following command:



    java -version


    It should display something similar to:



    java version "1.7.0_76"
    Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)



  3. (Optional) Remove the open-jdk if you really want/need to:



    sudo apt-get purge openjdk-*



You can find more information here






share|improve this answer


























  • Followed your directions and got a Unable to find java executable. Check JAVA_HOME and PATH environment variables. error

    – Zack S
    Jul 28 '15 at 16:59













  • surprised of finding my own answer one year later, this still works for Ubuntu 16.04 and oracle-java8-installer

    – toto_tico
    Jun 24 '16 at 13:06











  • Got this when adding the repo: W: The repository 'http://ppa.launchpad.net/natecarlson/maven3/ubuntu xenial Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

    – crockpotveggies
    Mar 20 '17 at 15:31



















8














After removing openjdk, try this approach that worked for me:



Install oracle jdk 7 on ubuntu server (tested with ubuntu 12.0.4)



sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer


some more info here: https://launchpad.net/~webupd8team/+archive/java



(note to adapt this for your version of jdk)






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f430434%2freplace-openjdk-with-oracle-jdk-on-ubuntu%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    78














    You can completely remove the OpenJDK and fresh Install Oracle Java JDK by following these steps:





    1. Remove OpenJDK completely by this command:



      sudo apt-get purge openjdk-*



    2. Download the Oracle Java JDK here.



      Note: download appropriate file, for example if your system is x64 Ubuntu (i.e, Debian) the download file is named like this: jdk-8u51-linux-x64.tar.gz



      To find which version is your OS, check here




    3. Create a folder named java in /usr/local/by this command:



      sudo mkdir -p /usr/local/java



    4. Copy the Downloaded file in the directory /usr/local/java. To do this, cd into directory where downloaded file is located and use this command for copying that file to /usr/local/java/:



      sudo cp -r jdk-8u51-linux-x64.tar.gz /usr/local/java/



    5. CD into /usr/local/java/ directory and extract that copied file by using this command:



      sudo tar xvzf jdk-8u51-linux-x64.tar.gz


    6. After extraction you must see a folder named jdk1.8.0_51.



    7. Update PATH file by opening /etc/profile file by the command sudo nano /etc/profile and paste the following at the end of the file:



      JAVA_HOME=/usr/local/java/jdk1.8.0_51
      PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
      export JAVA_HOME
      export PATH


    8. Save and exit.



    9. Tell the system that the new Oracle Java version is available by the following commands:



      sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_51/bin/java" 1
      sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_51/bin/javac" 1
      sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_51/bin/javaws" 1



    10. Make Oracle Java JDK as default by this following commands:



      sudo update-alternatives --set java /usr/local/java/jdk1.8.0_51/bin/java
      sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_51/bin/javac
      sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_51/bin/javaws



    11. Reload sytem wide PATH /etc/profile by this command:



      source /etc/profile


    12. Reboot your system.



    13. Check Java JDK version by java -version command . If installation is succesful, it will display like the following:



      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-xxx)
      Java HotSpot(TM) Server VM (build 25.51-xxx, mixed mode)



    That's it!



    Note: We Assumed that the downloaded file is named jdk-8u51-linux-x64.tar.gz and used this name in all the commands used in steps 2, 4 and 5. It may depends on the type of O.S, processor type (i.e., 32bit or 64bit)






    share|improve this answer





















    • 1





      Beside this is the correct way to manually install oracle-jdk there is a package available from WebUpd8 PPA which will be updated, too. So there is no need to install every new version manually. See my answer here: askubuntu.com/questions/466166/…

      – lschuetze
      Apr 1 '15 at 9:21






    • 2





      Instead of using the directory jdk1.8.0_51, create a symlink named just "jdk" to this directory and next time you update just extract the JDK tarball and recreate the symlink and you're done.

      – ColinM
      Aug 4 '15 at 18:37











    • for ubuntu users: theres a foolproof method below from @mihaic that works well for me

      – Carson Ip
      Dec 26 '15 at 8:30













    • You are rockstar

      – Bhupinder
      Dec 14 '16 at 15:09











    • Please note that if you want to download the JDK in Ubuntu Server (without GUI), you can use the following command: wget --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz" You can always copied the latest version by go back the Oracle download page and generate a new one.

      – Toan Nguyen
      Feb 22 '18 at 4:40
















    78














    You can completely remove the OpenJDK and fresh Install Oracle Java JDK by following these steps:





    1. Remove OpenJDK completely by this command:



      sudo apt-get purge openjdk-*



    2. Download the Oracle Java JDK here.



      Note: download appropriate file, for example if your system is x64 Ubuntu (i.e, Debian) the download file is named like this: jdk-8u51-linux-x64.tar.gz



      To find which version is your OS, check here




    3. Create a folder named java in /usr/local/by this command:



      sudo mkdir -p /usr/local/java



    4. Copy the Downloaded file in the directory /usr/local/java. To do this, cd into directory where downloaded file is located and use this command for copying that file to /usr/local/java/:



      sudo cp -r jdk-8u51-linux-x64.tar.gz /usr/local/java/



    5. CD into /usr/local/java/ directory and extract that copied file by using this command:



      sudo tar xvzf jdk-8u51-linux-x64.tar.gz


    6. After extraction you must see a folder named jdk1.8.0_51.



    7. Update PATH file by opening /etc/profile file by the command sudo nano /etc/profile and paste the following at the end of the file:



      JAVA_HOME=/usr/local/java/jdk1.8.0_51
      PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
      export JAVA_HOME
      export PATH


    8. Save and exit.



    9. Tell the system that the new Oracle Java version is available by the following commands:



      sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_51/bin/java" 1
      sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_51/bin/javac" 1
      sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_51/bin/javaws" 1



    10. Make Oracle Java JDK as default by this following commands:



      sudo update-alternatives --set java /usr/local/java/jdk1.8.0_51/bin/java
      sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_51/bin/javac
      sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_51/bin/javaws



    11. Reload sytem wide PATH /etc/profile by this command:



      source /etc/profile


    12. Reboot your system.



    13. Check Java JDK version by java -version command . If installation is succesful, it will display like the following:



      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-xxx)
      Java HotSpot(TM) Server VM (build 25.51-xxx, mixed mode)



    That's it!



    Note: We Assumed that the downloaded file is named jdk-8u51-linux-x64.tar.gz and used this name in all the commands used in steps 2, 4 and 5. It may depends on the type of O.S, processor type (i.e., 32bit or 64bit)






    share|improve this answer





















    • 1





      Beside this is the correct way to manually install oracle-jdk there is a package available from WebUpd8 PPA which will be updated, too. So there is no need to install every new version manually. See my answer here: askubuntu.com/questions/466166/…

      – lschuetze
      Apr 1 '15 at 9:21






    • 2





      Instead of using the directory jdk1.8.0_51, create a symlink named just "jdk" to this directory and next time you update just extract the JDK tarball and recreate the symlink and you're done.

      – ColinM
      Aug 4 '15 at 18:37











    • for ubuntu users: theres a foolproof method below from @mihaic that works well for me

      – Carson Ip
      Dec 26 '15 at 8:30













    • You are rockstar

      – Bhupinder
      Dec 14 '16 at 15:09











    • Please note that if you want to download the JDK in Ubuntu Server (without GUI), you can use the following command: wget --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz" You can always copied the latest version by go back the Oracle download page and generate a new one.

      – Toan Nguyen
      Feb 22 '18 at 4:40














    78












    78








    78







    You can completely remove the OpenJDK and fresh Install Oracle Java JDK by following these steps:





    1. Remove OpenJDK completely by this command:



      sudo apt-get purge openjdk-*



    2. Download the Oracle Java JDK here.



      Note: download appropriate file, for example if your system is x64 Ubuntu (i.e, Debian) the download file is named like this: jdk-8u51-linux-x64.tar.gz



      To find which version is your OS, check here




    3. Create a folder named java in /usr/local/by this command:



      sudo mkdir -p /usr/local/java



    4. Copy the Downloaded file in the directory /usr/local/java. To do this, cd into directory where downloaded file is located and use this command for copying that file to /usr/local/java/:



      sudo cp -r jdk-8u51-linux-x64.tar.gz /usr/local/java/



    5. CD into /usr/local/java/ directory and extract that copied file by using this command:



      sudo tar xvzf jdk-8u51-linux-x64.tar.gz


    6. After extraction you must see a folder named jdk1.8.0_51.



    7. Update PATH file by opening /etc/profile file by the command sudo nano /etc/profile and paste the following at the end of the file:



      JAVA_HOME=/usr/local/java/jdk1.8.0_51
      PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
      export JAVA_HOME
      export PATH


    8. Save and exit.



    9. Tell the system that the new Oracle Java version is available by the following commands:



      sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_51/bin/java" 1
      sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_51/bin/javac" 1
      sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_51/bin/javaws" 1



    10. Make Oracle Java JDK as default by this following commands:



      sudo update-alternatives --set java /usr/local/java/jdk1.8.0_51/bin/java
      sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_51/bin/javac
      sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_51/bin/javaws



    11. Reload sytem wide PATH /etc/profile by this command:



      source /etc/profile


    12. Reboot your system.



    13. Check Java JDK version by java -version command . If installation is succesful, it will display like the following:



      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-xxx)
      Java HotSpot(TM) Server VM (build 25.51-xxx, mixed mode)



    That's it!



    Note: We Assumed that the downloaded file is named jdk-8u51-linux-x64.tar.gz and used this name in all the commands used in steps 2, 4 and 5. It may depends on the type of O.S, processor type (i.e., 32bit or 64bit)






    share|improve this answer















    You can completely remove the OpenJDK and fresh Install Oracle Java JDK by following these steps:





    1. Remove OpenJDK completely by this command:



      sudo apt-get purge openjdk-*



    2. Download the Oracle Java JDK here.



      Note: download appropriate file, for example if your system is x64 Ubuntu (i.e, Debian) the download file is named like this: jdk-8u51-linux-x64.tar.gz



      To find which version is your OS, check here




    3. Create a folder named java in /usr/local/by this command:



      sudo mkdir -p /usr/local/java



    4. Copy the Downloaded file in the directory /usr/local/java. To do this, cd into directory where downloaded file is located and use this command for copying that file to /usr/local/java/:



      sudo cp -r jdk-8u51-linux-x64.tar.gz /usr/local/java/



    5. CD into /usr/local/java/ directory and extract that copied file by using this command:



      sudo tar xvzf jdk-8u51-linux-x64.tar.gz


    6. After extraction you must see a folder named jdk1.8.0_51.



    7. Update PATH file by opening /etc/profile file by the command sudo nano /etc/profile and paste the following at the end of the file:



      JAVA_HOME=/usr/local/java/jdk1.8.0_51
      PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
      export JAVA_HOME
      export PATH


    8. Save and exit.



    9. Tell the system that the new Oracle Java version is available by the following commands:



      sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_51/bin/java" 1
      sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_51/bin/javac" 1
      sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_51/bin/javaws" 1



    10. Make Oracle Java JDK as default by this following commands:



      sudo update-alternatives --set java /usr/local/java/jdk1.8.0_51/bin/java
      sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_51/bin/javac
      sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_51/bin/javaws



    11. Reload sytem wide PATH /etc/profile by this command:



      source /etc/profile


    12. Reboot your system.



    13. Check Java JDK version by java -version command . If installation is succesful, it will display like the following:



      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-xxx)
      Java HotSpot(TM) Server VM (build 25.51-xxx, mixed mode)



    That's it!



    Note: We Assumed that the downloaded file is named jdk-8u51-linux-x64.tar.gz and used this name in all the commands used in steps 2, 4 and 5. It may depends on the type of O.S, processor type (i.e., 32bit or 64bit)







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 6 at 4:05

























    answered Sep 21 '14 at 12:45









    Nithi2023Nithi2023

    89675




    89675








    • 1





      Beside this is the correct way to manually install oracle-jdk there is a package available from WebUpd8 PPA which will be updated, too. So there is no need to install every new version manually. See my answer here: askubuntu.com/questions/466166/…

      – lschuetze
      Apr 1 '15 at 9:21






    • 2





      Instead of using the directory jdk1.8.0_51, create a symlink named just "jdk" to this directory and next time you update just extract the JDK tarball and recreate the symlink and you're done.

      – ColinM
      Aug 4 '15 at 18:37











    • for ubuntu users: theres a foolproof method below from @mihaic that works well for me

      – Carson Ip
      Dec 26 '15 at 8:30













    • You are rockstar

      – Bhupinder
      Dec 14 '16 at 15:09











    • Please note that if you want to download the JDK in Ubuntu Server (without GUI), you can use the following command: wget --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz" You can always copied the latest version by go back the Oracle download page and generate a new one.

      – Toan Nguyen
      Feb 22 '18 at 4:40














    • 1





      Beside this is the correct way to manually install oracle-jdk there is a package available from WebUpd8 PPA which will be updated, too. So there is no need to install every new version manually. See my answer here: askubuntu.com/questions/466166/…

      – lschuetze
      Apr 1 '15 at 9:21






    • 2





      Instead of using the directory jdk1.8.0_51, create a symlink named just "jdk" to this directory and next time you update just extract the JDK tarball and recreate the symlink and you're done.

      – ColinM
      Aug 4 '15 at 18:37











    • for ubuntu users: theres a foolproof method below from @mihaic that works well for me

      – Carson Ip
      Dec 26 '15 at 8:30













    • You are rockstar

      – Bhupinder
      Dec 14 '16 at 15:09











    • Please note that if you want to download the JDK in Ubuntu Server (without GUI), you can use the following command: wget --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz" You can always copied the latest version by go back the Oracle download page and generate a new one.

      – Toan Nguyen
      Feb 22 '18 at 4:40








    1




    1





    Beside this is the correct way to manually install oracle-jdk there is a package available from WebUpd8 PPA which will be updated, too. So there is no need to install every new version manually. See my answer here: askubuntu.com/questions/466166/…

    – lschuetze
    Apr 1 '15 at 9:21





    Beside this is the correct way to manually install oracle-jdk there is a package available from WebUpd8 PPA which will be updated, too. So there is no need to install every new version manually. See my answer here: askubuntu.com/questions/466166/…

    – lschuetze
    Apr 1 '15 at 9:21




    2




    2





    Instead of using the directory jdk1.8.0_51, create a symlink named just "jdk" to this directory and next time you update just extract the JDK tarball and recreate the symlink and you're done.

    – ColinM
    Aug 4 '15 at 18:37





    Instead of using the directory jdk1.8.0_51, create a symlink named just "jdk" to this directory and next time you update just extract the JDK tarball and recreate the symlink and you're done.

    – ColinM
    Aug 4 '15 at 18:37













    for ubuntu users: theres a foolproof method below from @mihaic that works well for me

    – Carson Ip
    Dec 26 '15 at 8:30







    for ubuntu users: theres a foolproof method below from @mihaic that works well for me

    – Carson Ip
    Dec 26 '15 at 8:30















    You are rockstar

    – Bhupinder
    Dec 14 '16 at 15:09





    You are rockstar

    – Bhupinder
    Dec 14 '16 at 15:09













    Please note that if you want to download the JDK in Ubuntu Server (without GUI), you can use the following command: wget --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz" You can always copied the latest version by go back the Oracle download page and generate a new one.

    – Toan Nguyen
    Feb 22 '18 at 4:40





    Please note that if you want to download the JDK in Ubuntu Server (without GUI), you can use the following command: wget --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz" You can always copied the latest version by go back the Oracle download page and generate a new one.

    – Toan Nguyen
    Feb 22 '18 at 4:40













    20














    You don't need to remove openjdk in order to use / install the oracle's jdk. Just install the oracle's jdk and configure which java you want to use by configuring it with:



    sudo update-alternatives --config java


    You can find more help here: https://help.ubuntu.com/community/Java






    share|improve this answer


























    • I need a way to have only one java on my ubuntu. tnx.

      – little ali
      Mar 6 '14 at 11:48











    • This is a great answer. Groovy on Debian jessie forces openjdk to be installed, but the work I do requires (don't ask) the Oracle JDK for compilation. This option allowed me to leave both openjdk and oracle jdk installed so everything plays nicely. Thanks!

      – sanimalp
      Sep 8 '16 at 17:03











    • Perfect answer.. Thanks for this..:)

      – john400
      Sep 2 '17 at 3:07
















    20














    You don't need to remove openjdk in order to use / install the oracle's jdk. Just install the oracle's jdk and configure which java you want to use by configuring it with:



    sudo update-alternatives --config java


    You can find more help here: https://help.ubuntu.com/community/Java






    share|improve this answer


























    • I need a way to have only one java on my ubuntu. tnx.

      – little ali
      Mar 6 '14 at 11:48











    • This is a great answer. Groovy on Debian jessie forces openjdk to be installed, but the work I do requires (don't ask) the Oracle JDK for compilation. This option allowed me to leave both openjdk and oracle jdk installed so everything plays nicely. Thanks!

      – sanimalp
      Sep 8 '16 at 17:03











    • Perfect answer.. Thanks for this..:)

      – john400
      Sep 2 '17 at 3:07














    20












    20








    20







    You don't need to remove openjdk in order to use / install the oracle's jdk. Just install the oracle's jdk and configure which java you want to use by configuring it with:



    sudo update-alternatives --config java


    You can find more help here: https://help.ubuntu.com/community/Java






    share|improve this answer















    You don't need to remove openjdk in order to use / install the oracle's jdk. Just install the oracle's jdk and configure which java you want to use by configuring it with:



    sudo update-alternatives --config java


    You can find more help here: https://help.ubuntu.com/community/Java







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 6 '14 at 17:25









    Seth

    34.9k27112165




    34.9k27112165










    answered Mar 6 '14 at 11:31









    MyxMyx

    32114




    32114













    • I need a way to have only one java on my ubuntu. tnx.

      – little ali
      Mar 6 '14 at 11:48











    • This is a great answer. Groovy on Debian jessie forces openjdk to be installed, but the work I do requires (don't ask) the Oracle JDK for compilation. This option allowed me to leave both openjdk and oracle jdk installed so everything plays nicely. Thanks!

      – sanimalp
      Sep 8 '16 at 17:03











    • Perfect answer.. Thanks for this..:)

      – john400
      Sep 2 '17 at 3:07



















    • I need a way to have only one java on my ubuntu. tnx.

      – little ali
      Mar 6 '14 at 11:48











    • This is a great answer. Groovy on Debian jessie forces openjdk to be installed, but the work I do requires (don't ask) the Oracle JDK for compilation. This option allowed me to leave both openjdk and oracle jdk installed so everything plays nicely. Thanks!

      – sanimalp
      Sep 8 '16 at 17:03











    • Perfect answer.. Thanks for this..:)

      – john400
      Sep 2 '17 at 3:07

















    I need a way to have only one java on my ubuntu. tnx.

    – little ali
    Mar 6 '14 at 11:48





    I need a way to have only one java on my ubuntu. tnx.

    – little ali
    Mar 6 '14 at 11:48













    This is a great answer. Groovy on Debian jessie forces openjdk to be installed, but the work I do requires (don't ask) the Oracle JDK for compilation. This option allowed me to leave both openjdk and oracle jdk installed so everything plays nicely. Thanks!

    – sanimalp
    Sep 8 '16 at 17:03





    This is a great answer. Groovy on Debian jessie forces openjdk to be installed, but the work I do requires (don't ask) the Oracle JDK for compilation. This option allowed me to leave both openjdk and oracle jdk installed so everything plays nicely. Thanks!

    – sanimalp
    Sep 8 '16 at 17:03













    Perfect answer.. Thanks for this..:)

    – john400
    Sep 2 '17 at 3:07





    Perfect answer.. Thanks for this..:)

    – john400
    Sep 2 '17 at 3:07











    11














    Tested in Ubuntu 14.04/16.04. In three steps:





    1. Install the oracle-java7-installer (or oracle-java8-installer) from the webupd8team repository



      sudo add-apt-repository ppa:webupd8team/java
      sudo apt-get update
      sudo apt-get install oracle-java7-installer



    2. Make sure it works with the following command:



      java -version


      It should display something similar to:



      java version "1.7.0_76"
      Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)



    3. (Optional) Remove the open-jdk if you really want/need to:



      sudo apt-get purge openjdk-*



    You can find more information here






    share|improve this answer


























    • Followed your directions and got a Unable to find java executable. Check JAVA_HOME and PATH environment variables. error

      – Zack S
      Jul 28 '15 at 16:59













    • surprised of finding my own answer one year later, this still works for Ubuntu 16.04 and oracle-java8-installer

      – toto_tico
      Jun 24 '16 at 13:06











    • Got this when adding the repo: W: The repository 'http://ppa.launchpad.net/natecarlson/maven3/ubuntu xenial Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

      – crockpotveggies
      Mar 20 '17 at 15:31
















    11














    Tested in Ubuntu 14.04/16.04. In three steps:





    1. Install the oracle-java7-installer (or oracle-java8-installer) from the webupd8team repository



      sudo add-apt-repository ppa:webupd8team/java
      sudo apt-get update
      sudo apt-get install oracle-java7-installer



    2. Make sure it works with the following command:



      java -version


      It should display something similar to:



      java version "1.7.0_76"
      Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)



    3. (Optional) Remove the open-jdk if you really want/need to:



      sudo apt-get purge openjdk-*



    You can find more information here






    share|improve this answer


























    • Followed your directions and got a Unable to find java executable. Check JAVA_HOME and PATH environment variables. error

      – Zack S
      Jul 28 '15 at 16:59













    • surprised of finding my own answer one year later, this still works for Ubuntu 16.04 and oracle-java8-installer

      – toto_tico
      Jun 24 '16 at 13:06











    • Got this when adding the repo: W: The repository 'http://ppa.launchpad.net/natecarlson/maven3/ubuntu xenial Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

      – crockpotveggies
      Mar 20 '17 at 15:31














    11












    11








    11







    Tested in Ubuntu 14.04/16.04. In three steps:





    1. Install the oracle-java7-installer (or oracle-java8-installer) from the webupd8team repository



      sudo add-apt-repository ppa:webupd8team/java
      sudo apt-get update
      sudo apt-get install oracle-java7-installer



    2. Make sure it works with the following command:



      java -version


      It should display something similar to:



      java version "1.7.0_76"
      Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)



    3. (Optional) Remove the open-jdk if you really want/need to:



      sudo apt-get purge openjdk-*



    You can find more information here






    share|improve this answer















    Tested in Ubuntu 14.04/16.04. In three steps:





    1. Install the oracle-java7-installer (or oracle-java8-installer) from the webupd8team repository



      sudo add-apt-repository ppa:webupd8team/java
      sudo apt-get update
      sudo apt-get install oracle-java7-installer



    2. Make sure it works with the following command:



      java -version


      It should display something similar to:



      java version "1.7.0_76"
      Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)



    3. (Optional) Remove the open-jdk if you really want/need to:



      sudo apt-get purge openjdk-*



    You can find more information here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 18 '16 at 21:07

























    answered Jan 27 '15 at 18:28









    toto_ticototo_tico

    231138




    231138













    • Followed your directions and got a Unable to find java executable. Check JAVA_HOME and PATH environment variables. error

      – Zack S
      Jul 28 '15 at 16:59













    • surprised of finding my own answer one year later, this still works for Ubuntu 16.04 and oracle-java8-installer

      – toto_tico
      Jun 24 '16 at 13:06











    • Got this when adding the repo: W: The repository 'http://ppa.launchpad.net/natecarlson/maven3/ubuntu xenial Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

      – crockpotveggies
      Mar 20 '17 at 15:31



















    • Followed your directions and got a Unable to find java executable. Check JAVA_HOME and PATH environment variables. error

      – Zack S
      Jul 28 '15 at 16:59













    • surprised of finding my own answer one year later, this still works for Ubuntu 16.04 and oracle-java8-installer

      – toto_tico
      Jun 24 '16 at 13:06











    • Got this when adding the repo: W: The repository 'http://ppa.launchpad.net/natecarlson/maven3/ubuntu xenial Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

      – crockpotveggies
      Mar 20 '17 at 15:31

















    Followed your directions and got a Unable to find java executable. Check JAVA_HOME and PATH environment variables. error

    – Zack S
    Jul 28 '15 at 16:59







    Followed your directions and got a Unable to find java executable. Check JAVA_HOME and PATH environment variables. error

    – Zack S
    Jul 28 '15 at 16:59















    surprised of finding my own answer one year later, this still works for Ubuntu 16.04 and oracle-java8-installer

    – toto_tico
    Jun 24 '16 at 13:06





    surprised of finding my own answer one year later, this still works for Ubuntu 16.04 and oracle-java8-installer

    – toto_tico
    Jun 24 '16 at 13:06













    Got this when adding the repo: W: The repository 'http://ppa.launchpad.net/natecarlson/maven3/ubuntu xenial Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

    – crockpotveggies
    Mar 20 '17 at 15:31





    Got this when adding the repo: W: The repository 'http://ppa.launchpad.net/natecarlson/maven3/ubuntu xenial Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

    – crockpotveggies
    Mar 20 '17 at 15:31











    8














    After removing openjdk, try this approach that worked for me:



    Install oracle jdk 7 on ubuntu server (tested with ubuntu 12.0.4)



    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer


    some more info here: https://launchpad.net/~webupd8team/+archive/java



    (note to adapt this for your version of jdk)






    share|improve this answer




























      8














      After removing openjdk, try this approach that worked for me:



      Install oracle jdk 7 on ubuntu server (tested with ubuntu 12.0.4)



      sudo apt-get install python-software-properties
      sudo add-apt-repository ppa:webupd8team/java
      sudo apt-get update
      sudo apt-get install oracle-java7-installer


      some more info here: https://launchpad.net/~webupd8team/+archive/java



      (note to adapt this for your version of jdk)






      share|improve this answer


























        8












        8








        8







        After removing openjdk, try this approach that worked for me:



        Install oracle jdk 7 on ubuntu server (tested with ubuntu 12.0.4)



        sudo apt-get install python-software-properties
        sudo add-apt-repository ppa:webupd8team/java
        sudo apt-get update
        sudo apt-get install oracle-java7-installer


        some more info here: https://launchpad.net/~webupd8team/+archive/java



        (note to adapt this for your version of jdk)






        share|improve this answer













        After removing openjdk, try this approach that worked for me:



        Install oracle jdk 7 on ubuntu server (tested with ubuntu 12.0.4)



        sudo apt-get install python-software-properties
        sudo add-apt-repository ppa:webupd8team/java
        sudo apt-get update
        sudo apt-get install oracle-java7-installer


        some more info here: https://launchpad.net/~webupd8team/+archive/java



        (note to adapt this for your version of jdk)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 6 '14 at 11:31









        mihaicmihaic

        912




        912






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f430434%2freplace-openjdk-with-oracle-jdk-on-ubuntu%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to make a Squid Proxy server?

            Is this a new Fibonacci Identity?

            19世紀