Ubuntu: JAVA_HOME is not defined correctly












9















I am trying to install some software (Shibboleth) in Ubuntu 14.04. I already have Java 7 OpenJDK installed in /usr/lib/jvm/, and I have these lines in /usr/environment



JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export JAVA_HOME


If I type echo $JAVA_HOME I correctly get /usr/lib/jvm/java-7-openjdk-amd64.
However, when I try to install Shibboleth I always get Error: JAVA_HOME is not defined correctly. Cannot execute java.



Interestingly, if I type java command it works (it refers to /usr/lib/java which is a link to the right one). However, when I try to run bash bin/install.sh of Shibboleth, I get the JAVA_HOME error



I already tried setting JAVA_HOME to the jre folder with same result. Any ideas?










share|improve this question

























  • First install necessary packages apt-get install openjdk-7-jre-headless apt-get install tomcat7 and see.

    – Madura Harshana
    Jan 23 '16 at 17:59











  • I already have both of them installed

    – Arturo
    Jan 23 '16 at 18:11
















9















I am trying to install some software (Shibboleth) in Ubuntu 14.04. I already have Java 7 OpenJDK installed in /usr/lib/jvm/, and I have these lines in /usr/environment



JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export JAVA_HOME


If I type echo $JAVA_HOME I correctly get /usr/lib/jvm/java-7-openjdk-amd64.
However, when I try to install Shibboleth I always get Error: JAVA_HOME is not defined correctly. Cannot execute java.



Interestingly, if I type java command it works (it refers to /usr/lib/java which is a link to the right one). However, when I try to run bash bin/install.sh of Shibboleth, I get the JAVA_HOME error



I already tried setting JAVA_HOME to the jre folder with same result. Any ideas?










share|improve this question

























  • First install necessary packages apt-get install openjdk-7-jre-headless apt-get install tomcat7 and see.

    – Madura Harshana
    Jan 23 '16 at 17:59











  • I already have both of them installed

    – Arturo
    Jan 23 '16 at 18:11














9












9








9


2






I am trying to install some software (Shibboleth) in Ubuntu 14.04. I already have Java 7 OpenJDK installed in /usr/lib/jvm/, and I have these lines in /usr/environment



JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export JAVA_HOME


If I type echo $JAVA_HOME I correctly get /usr/lib/jvm/java-7-openjdk-amd64.
However, when I try to install Shibboleth I always get Error: JAVA_HOME is not defined correctly. Cannot execute java.



Interestingly, if I type java command it works (it refers to /usr/lib/java which is a link to the right one). However, when I try to run bash bin/install.sh of Shibboleth, I get the JAVA_HOME error



I already tried setting JAVA_HOME to the jre folder with same result. Any ideas?










share|improve this question
















I am trying to install some software (Shibboleth) in Ubuntu 14.04. I already have Java 7 OpenJDK installed in /usr/lib/jvm/, and I have these lines in /usr/environment



JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export JAVA_HOME


If I type echo $JAVA_HOME I correctly get /usr/lib/jvm/java-7-openjdk-amd64.
However, when I try to install Shibboleth I always get Error: JAVA_HOME is not defined correctly. Cannot execute java.



Interestingly, if I type java command it works (it refers to /usr/lib/java which is a link to the right one). However, when I try to run bash bin/install.sh of Shibboleth, I get the JAVA_HOME error



I already tried setting JAVA_HOME to the jre folder with same result. Any ideas?







java ubuntu openjdk java-home






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 23 '16 at 18:55







Arturo

















asked Jan 23 '16 at 17:40









ArturoArturo

1,8731155108




1,8731155108













  • First install necessary packages apt-get install openjdk-7-jre-headless apt-get install tomcat7 and see.

    – Madura Harshana
    Jan 23 '16 at 17:59











  • I already have both of them installed

    – Arturo
    Jan 23 '16 at 18:11



















  • First install necessary packages apt-get install openjdk-7-jre-headless apt-get install tomcat7 and see.

    – Madura Harshana
    Jan 23 '16 at 17:59











  • I already have both of them installed

    – Arturo
    Jan 23 '16 at 18:11

















First install necessary packages apt-get install openjdk-7-jre-headless apt-get install tomcat7 and see.

– Madura Harshana
Jan 23 '16 at 17:59





First install necessary packages apt-get install openjdk-7-jre-headless apt-get install tomcat7 and see.

– Madura Harshana
Jan 23 '16 at 17:59













I already have both of them installed

– Arturo
Jan 23 '16 at 18:11





I already have both of them installed

– Arturo
Jan 23 '16 at 18:11












4 Answers
4






active

oldest

votes


















17














Add both JAVA_HOME & PATH to your ~/.profile



export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH


And, add following to your /etc/profile.d/java.sh



JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JAVA_HOME
PATH=${JAVA_HOME}/bin:${PATH}
export PATH
JRE_HOME=/usr/lib/jvm/jre
export JRE_HOME
JAVA_OPTS="-XX:+AggressiveOpts -Xms256m -Xmx512m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
export JAVA_OPTS


For more info, Refer Documentation



Hope it helps.






share|improve this answer


























  • I tried this but same error. Interestingly, if I type "java" command it works. However, when I try to run "bash bin/install.sh" of Shibboleth, I get the JAVA_HOME error.

    – Arturo
    Jan 23 '16 at 18:05






  • 1





    Updated my answer, hope it helps now

    – Let'sRefactor
    Jan 23 '16 at 18:15











  • Still same error. Is it OK that all these variables are defined without quotes? I didn't even had a .bash_profile or /etc/profile.d/java.sh files

    – Arturo
    Jan 23 '16 at 18:46











  • Ubuntu use ~/.profile instead of ~/.bash_profile, updated my answer

    – Let'sRefactor
    Jan 23 '16 at 18:50











  • /etc/profile.d/java.sh you need to create one, use cat.

    – Let'sRefactor
    Jan 23 '16 at 18:54



















0














you should set the path to bin folder where java, javac files are found.
In your case it might be /usr/lib/jvm/java-7-openjdk-amd64/bin






share|improve this answer
























  • Already tried, same result. Please, note that I can run the command "java" properly. The error is displayed when I try to run bin/install.sh on Shibboleth.

    – Arturo
    Jan 23 '16 at 18:12



















0














According to Your editor.



sudo vim /etc/profile


add these 2 lines at the end of the file



export JAVA_HOME="/usr/lib/jvm/java-8-oracle"  
export PATH=JAVA_HOME/bin:$PATH


Then



source /etc/profile


Check



mvn -version





share|improve this answer

































    0














    I issue is that the install.sh script which you are running has the java path wrong.



    Edit the file using



        sudo nano idp-install.sh


    and change the line which corresponds to java path and add the correct java path. This will solve your problem.



    P.S. This solution is specific to the java path for Shibboleth installation.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      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%2fstackoverflow.com%2fquestions%2f34966648%2fubuntu-java-home-is-not-defined-correctly%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









      17














      Add both JAVA_HOME & PATH to your ~/.profile



      export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
      export PATH=$JAVA_HOME/bin:$PATH


      And, add following to your /etc/profile.d/java.sh



      JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
      export JAVA_HOME
      PATH=${JAVA_HOME}/bin:${PATH}
      export PATH
      JRE_HOME=/usr/lib/jvm/jre
      export JRE_HOME
      JAVA_OPTS="-XX:+AggressiveOpts -Xms256m -Xmx512m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
      export JAVA_OPTS


      For more info, Refer Documentation



      Hope it helps.






      share|improve this answer


























      • I tried this but same error. Interestingly, if I type "java" command it works. However, when I try to run "bash bin/install.sh" of Shibboleth, I get the JAVA_HOME error.

        – Arturo
        Jan 23 '16 at 18:05






      • 1





        Updated my answer, hope it helps now

        – Let'sRefactor
        Jan 23 '16 at 18:15











      • Still same error. Is it OK that all these variables are defined without quotes? I didn't even had a .bash_profile or /etc/profile.d/java.sh files

        – Arturo
        Jan 23 '16 at 18:46











      • Ubuntu use ~/.profile instead of ~/.bash_profile, updated my answer

        – Let'sRefactor
        Jan 23 '16 at 18:50











      • /etc/profile.d/java.sh you need to create one, use cat.

        – Let'sRefactor
        Jan 23 '16 at 18:54
















      17














      Add both JAVA_HOME & PATH to your ~/.profile



      export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
      export PATH=$JAVA_HOME/bin:$PATH


      And, add following to your /etc/profile.d/java.sh



      JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
      export JAVA_HOME
      PATH=${JAVA_HOME}/bin:${PATH}
      export PATH
      JRE_HOME=/usr/lib/jvm/jre
      export JRE_HOME
      JAVA_OPTS="-XX:+AggressiveOpts -Xms256m -Xmx512m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
      export JAVA_OPTS


      For more info, Refer Documentation



      Hope it helps.






      share|improve this answer


























      • I tried this but same error. Interestingly, if I type "java" command it works. However, when I try to run "bash bin/install.sh" of Shibboleth, I get the JAVA_HOME error.

        – Arturo
        Jan 23 '16 at 18:05






      • 1





        Updated my answer, hope it helps now

        – Let'sRefactor
        Jan 23 '16 at 18:15











      • Still same error. Is it OK that all these variables are defined without quotes? I didn't even had a .bash_profile or /etc/profile.d/java.sh files

        – Arturo
        Jan 23 '16 at 18:46











      • Ubuntu use ~/.profile instead of ~/.bash_profile, updated my answer

        – Let'sRefactor
        Jan 23 '16 at 18:50











      • /etc/profile.d/java.sh you need to create one, use cat.

        – Let'sRefactor
        Jan 23 '16 at 18:54














      17












      17








      17







      Add both JAVA_HOME & PATH to your ~/.profile



      export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
      export PATH=$JAVA_HOME/bin:$PATH


      And, add following to your /etc/profile.d/java.sh



      JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
      export JAVA_HOME
      PATH=${JAVA_HOME}/bin:${PATH}
      export PATH
      JRE_HOME=/usr/lib/jvm/jre
      export JRE_HOME
      JAVA_OPTS="-XX:+AggressiveOpts -Xms256m -Xmx512m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
      export JAVA_OPTS


      For more info, Refer Documentation



      Hope it helps.






      share|improve this answer















      Add both JAVA_HOME & PATH to your ~/.profile



      export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
      export PATH=$JAVA_HOME/bin:$PATH


      And, add following to your /etc/profile.d/java.sh



      JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
      export JAVA_HOME
      PATH=${JAVA_HOME}/bin:${PATH}
      export PATH
      JRE_HOME=/usr/lib/jvm/jre
      export JRE_HOME
      JAVA_OPTS="-XX:+AggressiveOpts -Xms256m -Xmx512m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
      export JAVA_OPTS


      For more info, Refer Documentation



      Hope it helps.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jan 23 '16 at 18:50

























      answered Jan 23 '16 at 17:56









      Let'sRefactorLet'sRefactor

      2,58641735




      2,58641735













      • I tried this but same error. Interestingly, if I type "java" command it works. However, when I try to run "bash bin/install.sh" of Shibboleth, I get the JAVA_HOME error.

        – Arturo
        Jan 23 '16 at 18:05






      • 1





        Updated my answer, hope it helps now

        – Let'sRefactor
        Jan 23 '16 at 18:15











      • Still same error. Is it OK that all these variables are defined without quotes? I didn't even had a .bash_profile or /etc/profile.d/java.sh files

        – Arturo
        Jan 23 '16 at 18:46











      • Ubuntu use ~/.profile instead of ~/.bash_profile, updated my answer

        – Let'sRefactor
        Jan 23 '16 at 18:50











      • /etc/profile.d/java.sh you need to create one, use cat.

        – Let'sRefactor
        Jan 23 '16 at 18:54



















      • I tried this but same error. Interestingly, if I type "java" command it works. However, when I try to run "bash bin/install.sh" of Shibboleth, I get the JAVA_HOME error.

        – Arturo
        Jan 23 '16 at 18:05






      • 1





        Updated my answer, hope it helps now

        – Let'sRefactor
        Jan 23 '16 at 18:15











      • Still same error. Is it OK that all these variables are defined without quotes? I didn't even had a .bash_profile or /etc/profile.d/java.sh files

        – Arturo
        Jan 23 '16 at 18:46











      • Ubuntu use ~/.profile instead of ~/.bash_profile, updated my answer

        – Let'sRefactor
        Jan 23 '16 at 18:50











      • /etc/profile.d/java.sh you need to create one, use cat.

        – Let'sRefactor
        Jan 23 '16 at 18:54

















      I tried this but same error. Interestingly, if I type "java" command it works. However, when I try to run "bash bin/install.sh" of Shibboleth, I get the JAVA_HOME error.

      – Arturo
      Jan 23 '16 at 18:05





      I tried this but same error. Interestingly, if I type "java" command it works. However, when I try to run "bash bin/install.sh" of Shibboleth, I get the JAVA_HOME error.

      – Arturo
      Jan 23 '16 at 18:05




      1




      1





      Updated my answer, hope it helps now

      – Let'sRefactor
      Jan 23 '16 at 18:15





      Updated my answer, hope it helps now

      – Let'sRefactor
      Jan 23 '16 at 18:15













      Still same error. Is it OK that all these variables are defined without quotes? I didn't even had a .bash_profile or /etc/profile.d/java.sh files

      – Arturo
      Jan 23 '16 at 18:46





      Still same error. Is it OK that all these variables are defined without quotes? I didn't even had a .bash_profile or /etc/profile.d/java.sh files

      – Arturo
      Jan 23 '16 at 18:46













      Ubuntu use ~/.profile instead of ~/.bash_profile, updated my answer

      – Let'sRefactor
      Jan 23 '16 at 18:50





      Ubuntu use ~/.profile instead of ~/.bash_profile, updated my answer

      – Let'sRefactor
      Jan 23 '16 at 18:50













      /etc/profile.d/java.sh you need to create one, use cat.

      – Let'sRefactor
      Jan 23 '16 at 18:54





      /etc/profile.d/java.sh you need to create one, use cat.

      – Let'sRefactor
      Jan 23 '16 at 18:54













      0














      you should set the path to bin folder where java, javac files are found.
      In your case it might be /usr/lib/jvm/java-7-openjdk-amd64/bin






      share|improve this answer
























      • Already tried, same result. Please, note that I can run the command "java" properly. The error is displayed when I try to run bin/install.sh on Shibboleth.

        – Arturo
        Jan 23 '16 at 18:12
















      0














      you should set the path to bin folder where java, javac files are found.
      In your case it might be /usr/lib/jvm/java-7-openjdk-amd64/bin






      share|improve this answer
























      • Already tried, same result. Please, note that I can run the command "java" properly. The error is displayed when I try to run bin/install.sh on Shibboleth.

        – Arturo
        Jan 23 '16 at 18:12














      0












      0








      0







      you should set the path to bin folder where java, javac files are found.
      In your case it might be /usr/lib/jvm/java-7-openjdk-amd64/bin






      share|improve this answer













      you should set the path to bin folder where java, javac files are found.
      In your case it might be /usr/lib/jvm/java-7-openjdk-amd64/bin







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jan 23 '16 at 17:48









      Bharath TejaBharath Teja

      11




      11













      • Already tried, same result. Please, note that I can run the command "java" properly. The error is displayed when I try to run bin/install.sh on Shibboleth.

        – Arturo
        Jan 23 '16 at 18:12



















      • Already tried, same result. Please, note that I can run the command "java" properly. The error is displayed when I try to run bin/install.sh on Shibboleth.

        – Arturo
        Jan 23 '16 at 18:12

















      Already tried, same result. Please, note that I can run the command "java" properly. The error is displayed when I try to run bin/install.sh on Shibboleth.

      – Arturo
      Jan 23 '16 at 18:12





      Already tried, same result. Please, note that I can run the command "java" properly. The error is displayed when I try to run bin/install.sh on Shibboleth.

      – Arturo
      Jan 23 '16 at 18:12











      0














      According to Your editor.



      sudo vim /etc/profile


      add these 2 lines at the end of the file



      export JAVA_HOME="/usr/lib/jvm/java-8-oracle"  
      export PATH=JAVA_HOME/bin:$PATH


      Then



      source /etc/profile


      Check



      mvn -version





      share|improve this answer






























        0














        According to Your editor.



        sudo vim /etc/profile


        add these 2 lines at the end of the file



        export JAVA_HOME="/usr/lib/jvm/java-8-oracle"  
        export PATH=JAVA_HOME/bin:$PATH


        Then



        source /etc/profile


        Check



        mvn -version





        share|improve this answer




























          0












          0








          0







          According to Your editor.



          sudo vim /etc/profile


          add these 2 lines at the end of the file



          export JAVA_HOME="/usr/lib/jvm/java-8-oracle"  
          export PATH=JAVA_HOME/bin:$PATH


          Then



          source /etc/profile


          Check



          mvn -version





          share|improve this answer















          According to Your editor.



          sudo vim /etc/profile


          add these 2 lines at the end of the file



          export JAVA_HOME="/usr/lib/jvm/java-8-oracle"  
          export PATH=JAVA_HOME/bin:$PATH


          Then



          source /etc/profile


          Check



          mvn -version






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 5 '18 at 7:48









          dkb

          1,17811424




          1,17811424










          answered Oct 5 '18 at 7:15









          Shubham Shubham

          11




          11























              0














              I issue is that the install.sh script which you are running has the java path wrong.



              Edit the file using



                  sudo nano idp-install.sh


              and change the line which corresponds to java path and add the correct java path. This will solve your problem.



              P.S. This solution is specific to the java path for Shibboleth installation.






              share|improve this answer




























                0














                I issue is that the install.sh script which you are running has the java path wrong.



                Edit the file using



                    sudo nano idp-install.sh


                and change the line which corresponds to java path and add the correct java path. This will solve your problem.



                P.S. This solution is specific to the java path for Shibboleth installation.






                share|improve this answer


























                  0












                  0








                  0







                  I issue is that the install.sh script which you are running has the java path wrong.



                  Edit the file using



                      sudo nano idp-install.sh


                  and change the line which corresponds to java path and add the correct java path. This will solve your problem.



                  P.S. This solution is specific to the java path for Shibboleth installation.






                  share|improve this answer













                  I issue is that the install.sh script which you are running has the java path wrong.



                  Edit the file using



                      sudo nano idp-install.sh


                  and change the line which corresponds to java path and add the correct java path. This will solve your problem.



                  P.S. This solution is specific to the java path for Shibboleth installation.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 20 '18 at 13:41









                  MashmoomMashmoom

                  415




                  415






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • 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%2fstackoverflow.com%2fquestions%2f34966648%2fubuntu-java-home-is-not-defined-correctly%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

                      Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

                      ts Property 'filter' does not exist on type '{}'

                      mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window