Check java version without java -version

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








up vote
6
down vote

favorite
1












I get the following error while trying to compile or run everything that has to do with java or javac:





Error occurred during initialization of VM
java/lang/ClassNotFoundException: error in opening JAR file <Zip file open error> /usr/lib/jvm/java-8-oracle/jre/lib/rt.jar


I've read here that i should uninstall and install again JDK, here it is written that I should know which version of java I have installed on my pc in order to uninstall-it.



To check the version installed i run java -version but i get the error mentioned above, how can i check my java version without that command?



I know that i have installed java 8 but i don't know precisely which version it is.










share|improve this question























  • "I know that i have installed java 8 but i don't know precisely which version it is." Installed how?
    – muru
    Apr 13 at 12:14














up vote
6
down vote

favorite
1












I get the following error while trying to compile or run everything that has to do with java or javac:





Error occurred during initialization of VM
java/lang/ClassNotFoundException: error in opening JAR file <Zip file open error> /usr/lib/jvm/java-8-oracle/jre/lib/rt.jar


I've read here that i should uninstall and install again JDK, here it is written that I should know which version of java I have installed on my pc in order to uninstall-it.



To check the version installed i run java -version but i get the error mentioned above, how can i check my java version without that command?



I know that i have installed java 8 but i don't know precisely which version it is.










share|improve this question























  • "I know that i have installed java 8 but i don't know precisely which version it is." Installed how?
    – muru
    Apr 13 at 12:14












up vote
6
down vote

favorite
1









up vote
6
down vote

favorite
1






1





I get the following error while trying to compile or run everything that has to do with java or javac:





Error occurred during initialization of VM
java/lang/ClassNotFoundException: error in opening JAR file <Zip file open error> /usr/lib/jvm/java-8-oracle/jre/lib/rt.jar


I've read here that i should uninstall and install again JDK, here it is written that I should know which version of java I have installed on my pc in order to uninstall-it.



To check the version installed i run java -version but i get the error mentioned above, how can i check my java version without that command?



I know that i have installed java 8 but i don't know precisely which version it is.










share|improve this question















I get the following error while trying to compile or run everything that has to do with java or javac:





Error occurred during initialization of VM
java/lang/ClassNotFoundException: error in opening JAR file <Zip file open error> /usr/lib/jvm/java-8-oracle/jre/lib/rt.jar


I've read here that i should uninstall and install again JDK, here it is written that I should know which version of java I have installed on my pc in order to uninstall-it.



To check the version installed i run java -version but i get the error mentioned above, how can i check my java version without that command?



I know that i have installed java 8 but i don't know precisely which version it is.







java jdk






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 at 10:45









David Foerster

26.1k1361106




26.1k1361106










asked Apr 13 at 8:47









Zeno Raiser

16011




16011











  • "I know that i have installed java 8 but i don't know precisely which version it is." Installed how?
    – muru
    Apr 13 at 12:14
















  • "I know that i have installed java 8 but i don't know precisely which version it is." Installed how?
    – muru
    Apr 13 at 12:14















"I know that i have installed java 8 but i don't know precisely which version it is." Installed how?
– muru
Apr 13 at 12:14




"I know that i have installed java 8 but i don't know precisely which version it is." Installed how?
– muru
Apr 13 at 12:14










4 Answers
4






active

oldest

votes

















up vote
2
down vote



accepted










You can use this command for checking your java version:



update-alternatives --config java





share|improve this answer


















  • 7




    Wouldn't update-alternatives --display java be simpler and better since OP only wants to “display” available Java versions, not change the default? That wouldn't even require sudo.
    – David Foerster
    Apr 13 at 10:47


















up vote
6
down vote













To show what version of Java is installed without running java -version, open the terminal and type:





apt policy openjdk-* oracle-java* 


A small part of the results of apt policy openjdk-* looks like this:



openjdk-7-jre-lib:
Installed: (none)
Candidate: (none)
Version table:
openjdk-8-jdk:
Installed: 8u162-b12-0ubuntu0.16.04.2
Candidate: 8u162-b12-0ubuntu0.16.04.2


Search for sections that contain either openjdk-*-jre , openjdk-*-jdk or oracle-java* where the wildcard * character can be a Java version number like 6, 7, 8 or 9.






share|improve this answer






















  • thanks, with that command i got tons of lines which one should i search for?
    – Zeno Raiser
    Apr 13 at 8:57

















up vote
4
down vote













You can discover the full path of the default java executable with:





readlink -f "$(which java)"


All (sane) Java packages or bundles that I know use installation path names that include the vendor name and major version number which would answer your question. E. g. on my system



$ readlink -f "$(which java)"
/usr/lib/jvm/java-9-openjdk-amd64/bin/java


tells me that the default Java installation is OpenJDK 9.






share|improve this answer



























    up vote
    2
    down vote













    You could also try:



    dpkg -l | egrep -i 'jre|java|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',
      convertImagesToLinks: true,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      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%2faskubuntu.com%2fquestions%2f1024582%2fcheck-java-version-without-java-version%23new-answer', 'question_page');

      );

      Post as a guest






























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote



      accepted










      You can use this command for checking your java version:



      update-alternatives --config java





      share|improve this answer


















      • 7




        Wouldn't update-alternatives --display java be simpler and better since OP only wants to “display” available Java versions, not change the default? That wouldn't even require sudo.
        – David Foerster
        Apr 13 at 10:47















      up vote
      2
      down vote



      accepted










      You can use this command for checking your java version:



      update-alternatives --config java





      share|improve this answer


















      • 7




        Wouldn't update-alternatives --display java be simpler and better since OP only wants to “display” available Java versions, not change the default? That wouldn't even require sudo.
        – David Foerster
        Apr 13 at 10:47













      up vote
      2
      down vote



      accepted







      up vote
      2
      down vote



      accepted






      You can use this command for checking your java version:



      update-alternatives --config java





      share|improve this answer














      You can use this command for checking your java version:



      update-alternatives --config java






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 18 at 6:49









      Campa

      366411




      366411










      answered Apr 13 at 9:00









      Eranda Peiris

      661416




      661416







      • 7




        Wouldn't update-alternatives --display java be simpler and better since OP only wants to “display” available Java versions, not change the default? That wouldn't even require sudo.
        – David Foerster
        Apr 13 at 10:47













      • 7




        Wouldn't update-alternatives --display java be simpler and better since OP only wants to “display” available Java versions, not change the default? That wouldn't even require sudo.
        – David Foerster
        Apr 13 at 10:47








      7




      7




      Wouldn't update-alternatives --display java be simpler and better since OP only wants to “display” available Java versions, not change the default? That wouldn't even require sudo.
      – David Foerster
      Apr 13 at 10:47





      Wouldn't update-alternatives --display java be simpler and better since OP only wants to “display” available Java versions, not change the default? That wouldn't even require sudo.
      – David Foerster
      Apr 13 at 10:47













      up vote
      6
      down vote













      To show what version of Java is installed without running java -version, open the terminal and type:





      apt policy openjdk-* oracle-java* 


      A small part of the results of apt policy openjdk-* looks like this:



      openjdk-7-jre-lib:
      Installed: (none)
      Candidate: (none)
      Version table:
      openjdk-8-jdk:
      Installed: 8u162-b12-0ubuntu0.16.04.2
      Candidate: 8u162-b12-0ubuntu0.16.04.2


      Search for sections that contain either openjdk-*-jre , openjdk-*-jdk or oracle-java* where the wildcard * character can be a Java version number like 6, 7, 8 or 9.






      share|improve this answer






















      • thanks, with that command i got tons of lines which one should i search for?
        – Zeno Raiser
        Apr 13 at 8:57














      up vote
      6
      down vote













      To show what version of Java is installed without running java -version, open the terminal and type:





      apt policy openjdk-* oracle-java* 


      A small part of the results of apt policy openjdk-* looks like this:



      openjdk-7-jre-lib:
      Installed: (none)
      Candidate: (none)
      Version table:
      openjdk-8-jdk:
      Installed: 8u162-b12-0ubuntu0.16.04.2
      Candidate: 8u162-b12-0ubuntu0.16.04.2


      Search for sections that contain either openjdk-*-jre , openjdk-*-jdk or oracle-java* where the wildcard * character can be a Java version number like 6, 7, 8 or 9.






      share|improve this answer






















      • thanks, with that command i got tons of lines which one should i search for?
        – Zeno Raiser
        Apr 13 at 8:57












      up vote
      6
      down vote










      up vote
      6
      down vote









      To show what version of Java is installed without running java -version, open the terminal and type:





      apt policy openjdk-* oracle-java* 


      A small part of the results of apt policy openjdk-* looks like this:



      openjdk-7-jre-lib:
      Installed: (none)
      Candidate: (none)
      Version table:
      openjdk-8-jdk:
      Installed: 8u162-b12-0ubuntu0.16.04.2
      Candidate: 8u162-b12-0ubuntu0.16.04.2


      Search for sections that contain either openjdk-*-jre , openjdk-*-jdk or oracle-java* where the wildcard * character can be a Java version number like 6, 7, 8 or 9.






      share|improve this answer














      To show what version of Java is installed without running java -version, open the terminal and type:





      apt policy openjdk-* oracle-java* 


      A small part of the results of apt policy openjdk-* looks like this:



      openjdk-7-jre-lib:
      Installed: (none)
      Candidate: (none)
      Version table:
      openjdk-8-jdk:
      Installed: 8u162-b12-0ubuntu0.16.04.2
      Candidate: 8u162-b12-0ubuntu0.16.04.2


      Search for sections that contain either openjdk-*-jre , openjdk-*-jdk or oracle-java* where the wildcard * character can be a Java version number like 6, 7, 8 or 9.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 13 at 10:52

























      answered Apr 13 at 8:53









      karel

      50.5k11107127




      50.5k11107127











      • thanks, with that command i got tons of lines which one should i search for?
        – Zeno Raiser
        Apr 13 at 8:57
















      • thanks, with that command i got tons of lines which one should i search for?
        – Zeno Raiser
        Apr 13 at 8:57















      thanks, with that command i got tons of lines which one should i search for?
      – Zeno Raiser
      Apr 13 at 8:57




      thanks, with that command i got tons of lines which one should i search for?
      – Zeno Raiser
      Apr 13 at 8:57










      up vote
      4
      down vote













      You can discover the full path of the default java executable with:





      readlink -f "$(which java)"


      All (sane) Java packages or bundles that I know use installation path names that include the vendor name and major version number which would answer your question. E. g. on my system



      $ readlink -f "$(which java)"
      /usr/lib/jvm/java-9-openjdk-amd64/bin/java


      tells me that the default Java installation is OpenJDK 9.






      share|improve this answer
























        up vote
        4
        down vote













        You can discover the full path of the default java executable with:





        readlink -f "$(which java)"


        All (sane) Java packages or bundles that I know use installation path names that include the vendor name and major version number which would answer your question. E. g. on my system



        $ readlink -f "$(which java)"
        /usr/lib/jvm/java-9-openjdk-amd64/bin/java


        tells me that the default Java installation is OpenJDK 9.






        share|improve this answer






















          up vote
          4
          down vote










          up vote
          4
          down vote









          You can discover the full path of the default java executable with:





          readlink -f "$(which java)"


          All (sane) Java packages or bundles that I know use installation path names that include the vendor name and major version number which would answer your question. E. g. on my system



          $ readlink -f "$(which java)"
          /usr/lib/jvm/java-9-openjdk-amd64/bin/java


          tells me that the default Java installation is OpenJDK 9.






          share|improve this answer












          You can discover the full path of the default java executable with:





          readlink -f "$(which java)"


          All (sane) Java packages or bundles that I know use installation path names that include the vendor name and major version number which would answer your question. E. g. on my system



          $ readlink -f "$(which java)"
          /usr/lib/jvm/java-9-openjdk-amd64/bin/java


          tells me that the default Java installation is OpenJDK 9.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 13 at 10:54









          David Foerster

          26.1k1361106




          26.1k1361106




















              up vote
              2
              down vote













              You could also try:



              dpkg -l | egrep -i 'jre|java|jdk'





              share|improve this answer


























                up vote
                2
                down vote













                You could also try:



                dpkg -l | egrep -i 'jre|java|jdk'





                share|improve this answer
























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  You could also try:



                  dpkg -l | egrep -i 'jre|java|jdk'





                  share|improve this answer














                  You could also try:



                  dpkg -l | egrep -i 'jre|java|jdk'






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 13 at 10:50









                  David Foerster

                  26.1k1361106




                  26.1k1361106










                  answered Apr 13 at 10:17









                  muclux

                  2,1231522




                  2,1231522



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1024582%2fcheck-java-version-without-java-version%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      Which professions warranted travel in Medieval times?

                      How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

                      Trouble downloading packages list due to a “Hash sum mismatch” error