Ways to configure alternative installations of Oracle JDK on Ubuntu?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












When installing the latest Oracle JDK (8 or 9) on Ubuntu 16.04, I found several discussions:



  • https://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre/


  • https://askubuntu.com/questions/521145/how-to-install-oracle-java-on-ubuntu-14-04


  • https://askubuntu.com/questions/159575/how-do-i-make-java-default-to-a-manually-installed-jre-jdk


  • https://unix.stackexchange.com/a/418855/674


I summarize their ways into the following:



  • Some use update-alternatives. Among them, some use it for java, javac and javaws (example), while some use it for more commands (
    example, example, example, example). I am not sure which one gives the complete list of commands to apply update-alternatives to.


  • Some use update-java-alternatives (example, example, ), but some says it doesn't work for manual installation.


  • Some use both update-alternatives and update-java-alternatives (example)


  • Some change several environment variables, and think that the previous two approaches are complicated unnecessarily (example, )


  • Some both use update-alternatives and change several environment variables: (example)


  • Some install from ppa:webupd8team/java (example, example, example)


I wonder which way(s) is recommended?



Thanks.







share|improve this question




















  • Any way that works for you.
    – TheWanderer
    Jan 23 at 2:12










  • I guess Stephen doesn't think so unix.stackexchange.com/a/418855/674
    – Tim
    Jan 23 at 2:23















up vote
2
down vote

favorite












When installing the latest Oracle JDK (8 or 9) on Ubuntu 16.04, I found several discussions:



  • https://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre/


  • https://askubuntu.com/questions/521145/how-to-install-oracle-java-on-ubuntu-14-04


  • https://askubuntu.com/questions/159575/how-do-i-make-java-default-to-a-manually-installed-jre-jdk


  • https://unix.stackexchange.com/a/418855/674


I summarize their ways into the following:



  • Some use update-alternatives. Among them, some use it for java, javac and javaws (example), while some use it for more commands (
    example, example, example, example). I am not sure which one gives the complete list of commands to apply update-alternatives to.


  • Some use update-java-alternatives (example, example, ), but some says it doesn't work for manual installation.


  • Some use both update-alternatives and update-java-alternatives (example)


  • Some change several environment variables, and think that the previous two approaches are complicated unnecessarily (example, )


  • Some both use update-alternatives and change several environment variables: (example)


  • Some install from ppa:webupd8team/java (example, example, example)


I wonder which way(s) is recommended?



Thanks.







share|improve this question




















  • Any way that works for you.
    – TheWanderer
    Jan 23 at 2:12










  • I guess Stephen doesn't think so unix.stackexchange.com/a/418855/674
    – Tim
    Jan 23 at 2:23













up vote
2
down vote

favorite









up vote
2
down vote

favorite











When installing the latest Oracle JDK (8 or 9) on Ubuntu 16.04, I found several discussions:



  • https://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre/


  • https://askubuntu.com/questions/521145/how-to-install-oracle-java-on-ubuntu-14-04


  • https://askubuntu.com/questions/159575/how-do-i-make-java-default-to-a-manually-installed-jre-jdk


  • https://unix.stackexchange.com/a/418855/674


I summarize their ways into the following:



  • Some use update-alternatives. Among them, some use it for java, javac and javaws (example), while some use it for more commands (
    example, example, example, example). I am not sure which one gives the complete list of commands to apply update-alternatives to.


  • Some use update-java-alternatives (example, example, ), but some says it doesn't work for manual installation.


  • Some use both update-alternatives and update-java-alternatives (example)


  • Some change several environment variables, and think that the previous two approaches are complicated unnecessarily (example, )


  • Some both use update-alternatives and change several environment variables: (example)


  • Some install from ppa:webupd8team/java (example, example, example)


I wonder which way(s) is recommended?



Thanks.







share|improve this question












When installing the latest Oracle JDK (8 or 9) on Ubuntu 16.04, I found several discussions:



  • https://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre/


  • https://askubuntu.com/questions/521145/how-to-install-oracle-java-on-ubuntu-14-04


  • https://askubuntu.com/questions/159575/how-do-i-make-java-default-to-a-manually-installed-jre-jdk


  • https://unix.stackexchange.com/a/418855/674


I summarize their ways into the following:



  • Some use update-alternatives. Among them, some use it for java, javac and javaws (example), while some use it for more commands (
    example, example, example, example). I am not sure which one gives the complete list of commands to apply update-alternatives to.


  • Some use update-java-alternatives (example, example, ), but some says it doesn't work for manual installation.


  • Some use both update-alternatives and update-java-alternatives (example)


  • Some change several environment variables, and think that the previous two approaches are complicated unnecessarily (example, )


  • Some both use update-alternatives and change several environment variables: (example)


  • Some install from ppa:webupd8team/java (example, example, example)


I wonder which way(s) is recommended?



Thanks.









share|improve this question











share|improve this question




share|improve this question










asked Jan 23 at 1:54









Tim

22.7k65224403




22.7k65224403











  • Any way that works for you.
    – TheWanderer
    Jan 23 at 2:12










  • I guess Stephen doesn't think so unix.stackexchange.com/a/418855/674
    – Tim
    Jan 23 at 2:23

















  • Any way that works for you.
    – TheWanderer
    Jan 23 at 2:12










  • I guess Stephen doesn't think so unix.stackexchange.com/a/418855/674
    – Tim
    Jan 23 at 2:23
















Any way that works for you.
– TheWanderer
Jan 23 at 2:12




Any way that works for you.
– TheWanderer
Jan 23 at 2:12












I guess Stephen doesn't think so unix.stackexchange.com/a/418855/674
– Tim
Jan 23 at 2:23





I guess Stephen doesn't think so unix.stackexchange.com/a/418855/674
– Tim
Jan 23 at 2:23











1 Answer
1






active

oldest

votes

















up vote
4
down vote













When I say that I recommend update-java-alternatives for Java alternatives, I’m assuming that whatever Java providers are installed provide the necessary infrastructure. That’s the case for the OpenJDK packages available in Debian and its derivatives, but not necessarily for other JDK packages, and it’s unlikely to be the case for a manually-installed JDK. Oracle JDK packages created using java-package do provide the necessary infrastructure. I don’t think it’s a sensible use of people’s time to set up the alternatives for all the Java commands manually: if you want to install the Oracle JRE or JDK, use java-package.



The point of update-java-alternatives is to allow a consistent setup of the default JRE/JDK tools. In theory, this could be done using update-alternatives’ --slave relationships; however that doesn’t work generally for OpenJDK packages because you can have a subset of the available tools installed, which update-alternatives doesn’t deal with. Hence the creation of update-java-alternatives, which takes care of whatever tools are installed and doesn’t complain about anything else. For update-java-alternatives to work though, JRE/JDK packages have to provide the necessary information, in a file in /usr/lib/jvm (e.g. .java-1.8.0-openjdk-amd64.jinfo). (update-alternatives on RPM-based distributions does cope with this, apparently, but I haven’t looked into the details.)



Java itself has its own way of choosing among multiple installed JREs/JDKs, the JAVA_HOME environment variable. update-java-alternatives and JAVA_HOME are really complementary: it should be possible to set both to point at different JREs/JDKs, depending on your requirements. update-java-alternatives allows the system administrator to specify which JRE/JDK should be the default on a system (in fact, one might consider that it allows the package maintainers to specify which should be the default — it’s all supposed to work transparently for the administrators and users). JAVA_HOME allows any user or startup script to specify which JRE/JDK should be used in a specific environment. Where things fall apart somewhat on Unix-style systems is with PATH-handling, since PATH can’t be set to dynamically use JAVA_HOME to choose java, javac etc. (unlike on Windows); so you need to remember to re-set your PATH when you change your JAVA_HOME, if you want your default java etc. to track your JAVA_HOME setting (add $JAVA_HOME/bin to the start of your PATH).



The take-away from all this is similar to my answer to Can setting up environment variables replace using `update-alternatives`?: the system administrator should use update-java-alternatives to define the default JRE/JDK for the system (or let the packages choose themselves), and users can use JAVA_HOME to define the JRE/JDK for a specific environment.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418985%2fways-to-configure-alternative-installations-of-oracle-jdk-on-ubuntu%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote













    When I say that I recommend update-java-alternatives for Java alternatives, I’m assuming that whatever Java providers are installed provide the necessary infrastructure. That’s the case for the OpenJDK packages available in Debian and its derivatives, but not necessarily for other JDK packages, and it’s unlikely to be the case for a manually-installed JDK. Oracle JDK packages created using java-package do provide the necessary infrastructure. I don’t think it’s a sensible use of people’s time to set up the alternatives for all the Java commands manually: if you want to install the Oracle JRE or JDK, use java-package.



    The point of update-java-alternatives is to allow a consistent setup of the default JRE/JDK tools. In theory, this could be done using update-alternatives’ --slave relationships; however that doesn’t work generally for OpenJDK packages because you can have a subset of the available tools installed, which update-alternatives doesn’t deal with. Hence the creation of update-java-alternatives, which takes care of whatever tools are installed and doesn’t complain about anything else. For update-java-alternatives to work though, JRE/JDK packages have to provide the necessary information, in a file in /usr/lib/jvm (e.g. .java-1.8.0-openjdk-amd64.jinfo). (update-alternatives on RPM-based distributions does cope with this, apparently, but I haven’t looked into the details.)



    Java itself has its own way of choosing among multiple installed JREs/JDKs, the JAVA_HOME environment variable. update-java-alternatives and JAVA_HOME are really complementary: it should be possible to set both to point at different JREs/JDKs, depending on your requirements. update-java-alternatives allows the system administrator to specify which JRE/JDK should be the default on a system (in fact, one might consider that it allows the package maintainers to specify which should be the default — it’s all supposed to work transparently for the administrators and users). JAVA_HOME allows any user or startup script to specify which JRE/JDK should be used in a specific environment. Where things fall apart somewhat on Unix-style systems is with PATH-handling, since PATH can’t be set to dynamically use JAVA_HOME to choose java, javac etc. (unlike on Windows); so you need to remember to re-set your PATH when you change your JAVA_HOME, if you want your default java etc. to track your JAVA_HOME setting (add $JAVA_HOME/bin to the start of your PATH).



    The take-away from all this is similar to my answer to Can setting up environment variables replace using `update-alternatives`?: the system administrator should use update-java-alternatives to define the default JRE/JDK for the system (or let the packages choose themselves), and users can use JAVA_HOME to define the JRE/JDK for a specific environment.






    share|improve this answer
























      up vote
      4
      down vote













      When I say that I recommend update-java-alternatives for Java alternatives, I’m assuming that whatever Java providers are installed provide the necessary infrastructure. That’s the case for the OpenJDK packages available in Debian and its derivatives, but not necessarily for other JDK packages, and it’s unlikely to be the case for a manually-installed JDK. Oracle JDK packages created using java-package do provide the necessary infrastructure. I don’t think it’s a sensible use of people’s time to set up the alternatives for all the Java commands manually: if you want to install the Oracle JRE or JDK, use java-package.



      The point of update-java-alternatives is to allow a consistent setup of the default JRE/JDK tools. In theory, this could be done using update-alternatives’ --slave relationships; however that doesn’t work generally for OpenJDK packages because you can have a subset of the available tools installed, which update-alternatives doesn’t deal with. Hence the creation of update-java-alternatives, which takes care of whatever tools are installed and doesn’t complain about anything else. For update-java-alternatives to work though, JRE/JDK packages have to provide the necessary information, in a file in /usr/lib/jvm (e.g. .java-1.8.0-openjdk-amd64.jinfo). (update-alternatives on RPM-based distributions does cope with this, apparently, but I haven’t looked into the details.)



      Java itself has its own way of choosing among multiple installed JREs/JDKs, the JAVA_HOME environment variable. update-java-alternatives and JAVA_HOME are really complementary: it should be possible to set both to point at different JREs/JDKs, depending on your requirements. update-java-alternatives allows the system administrator to specify which JRE/JDK should be the default on a system (in fact, one might consider that it allows the package maintainers to specify which should be the default — it’s all supposed to work transparently for the administrators and users). JAVA_HOME allows any user or startup script to specify which JRE/JDK should be used in a specific environment. Where things fall apart somewhat on Unix-style systems is with PATH-handling, since PATH can’t be set to dynamically use JAVA_HOME to choose java, javac etc. (unlike on Windows); so you need to remember to re-set your PATH when you change your JAVA_HOME, if you want your default java etc. to track your JAVA_HOME setting (add $JAVA_HOME/bin to the start of your PATH).



      The take-away from all this is similar to my answer to Can setting up environment variables replace using `update-alternatives`?: the system administrator should use update-java-alternatives to define the default JRE/JDK for the system (or let the packages choose themselves), and users can use JAVA_HOME to define the JRE/JDK for a specific environment.






      share|improve this answer






















        up vote
        4
        down vote










        up vote
        4
        down vote









        When I say that I recommend update-java-alternatives for Java alternatives, I’m assuming that whatever Java providers are installed provide the necessary infrastructure. That’s the case for the OpenJDK packages available in Debian and its derivatives, but not necessarily for other JDK packages, and it’s unlikely to be the case for a manually-installed JDK. Oracle JDK packages created using java-package do provide the necessary infrastructure. I don’t think it’s a sensible use of people’s time to set up the alternatives for all the Java commands manually: if you want to install the Oracle JRE or JDK, use java-package.



        The point of update-java-alternatives is to allow a consistent setup of the default JRE/JDK tools. In theory, this could be done using update-alternatives’ --slave relationships; however that doesn’t work generally for OpenJDK packages because you can have a subset of the available tools installed, which update-alternatives doesn’t deal with. Hence the creation of update-java-alternatives, which takes care of whatever tools are installed and doesn’t complain about anything else. For update-java-alternatives to work though, JRE/JDK packages have to provide the necessary information, in a file in /usr/lib/jvm (e.g. .java-1.8.0-openjdk-amd64.jinfo). (update-alternatives on RPM-based distributions does cope with this, apparently, but I haven’t looked into the details.)



        Java itself has its own way of choosing among multiple installed JREs/JDKs, the JAVA_HOME environment variable. update-java-alternatives and JAVA_HOME are really complementary: it should be possible to set both to point at different JREs/JDKs, depending on your requirements. update-java-alternatives allows the system administrator to specify which JRE/JDK should be the default on a system (in fact, one might consider that it allows the package maintainers to specify which should be the default — it’s all supposed to work transparently for the administrators and users). JAVA_HOME allows any user or startup script to specify which JRE/JDK should be used in a specific environment. Where things fall apart somewhat on Unix-style systems is with PATH-handling, since PATH can’t be set to dynamically use JAVA_HOME to choose java, javac etc. (unlike on Windows); so you need to remember to re-set your PATH when you change your JAVA_HOME, if you want your default java etc. to track your JAVA_HOME setting (add $JAVA_HOME/bin to the start of your PATH).



        The take-away from all this is similar to my answer to Can setting up environment variables replace using `update-alternatives`?: the system administrator should use update-java-alternatives to define the default JRE/JDK for the system (or let the packages choose themselves), and users can use JAVA_HOME to define the JRE/JDK for a specific environment.






        share|improve this answer












        When I say that I recommend update-java-alternatives for Java alternatives, I’m assuming that whatever Java providers are installed provide the necessary infrastructure. That’s the case for the OpenJDK packages available in Debian and its derivatives, but not necessarily for other JDK packages, and it’s unlikely to be the case for a manually-installed JDK. Oracle JDK packages created using java-package do provide the necessary infrastructure. I don’t think it’s a sensible use of people’s time to set up the alternatives for all the Java commands manually: if you want to install the Oracle JRE or JDK, use java-package.



        The point of update-java-alternatives is to allow a consistent setup of the default JRE/JDK tools. In theory, this could be done using update-alternatives’ --slave relationships; however that doesn’t work generally for OpenJDK packages because you can have a subset of the available tools installed, which update-alternatives doesn’t deal with. Hence the creation of update-java-alternatives, which takes care of whatever tools are installed and doesn’t complain about anything else. For update-java-alternatives to work though, JRE/JDK packages have to provide the necessary information, in a file in /usr/lib/jvm (e.g. .java-1.8.0-openjdk-amd64.jinfo). (update-alternatives on RPM-based distributions does cope with this, apparently, but I haven’t looked into the details.)



        Java itself has its own way of choosing among multiple installed JREs/JDKs, the JAVA_HOME environment variable. update-java-alternatives and JAVA_HOME are really complementary: it should be possible to set both to point at different JREs/JDKs, depending on your requirements. update-java-alternatives allows the system administrator to specify which JRE/JDK should be the default on a system (in fact, one might consider that it allows the package maintainers to specify which should be the default — it’s all supposed to work transparently for the administrators and users). JAVA_HOME allows any user or startup script to specify which JRE/JDK should be used in a specific environment. Where things fall apart somewhat on Unix-style systems is with PATH-handling, since PATH can’t be set to dynamically use JAVA_HOME to choose java, javac etc. (unlike on Windows); so you need to remember to re-set your PATH when you change your JAVA_HOME, if you want your default java etc. to track your JAVA_HOME setting (add $JAVA_HOME/bin to the start of your PATH).



        The take-away from all this is similar to my answer to Can setting up environment variables replace using `update-alternatives`?: the system administrator should use update-java-alternatives to define the default JRE/JDK for the system (or let the packages choose themselves), and users can use JAVA_HOME to define the JRE/JDK for a specific environment.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 23 at 8:10









        Stephen Kitt

        142k22308371




        142k22308371






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418985%2fways-to-configure-alternative-installations-of-oracle-jdk-on-ubuntu%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay