Which JRE am I using?

后端 未结 9 1202
暗喜
暗喜 2020-12-02 16:29

There are two varieties of JRE available. Java VM: IBM vs. Sun.

Is there a way to know which JRE I am using through JavaScript or some Java issued command.

相关标签:
9条回答
  • 2020-12-02 17:02

    The following command will tell you a lot of information about your java version, including the vendor:

    java -XshowSettings:properties -version
    

    It works on Windows, Mac, and Linux.

    0 讨论(0)
  • 2020-12-02 17:05
    1. Open up your:
      • command prompt if you're using Windows
      • terminal if you're using mac or Linux
    2. Type in:

      java -version // This will check your JRE version
      javac -version // This will check your Java compiler version if you installed the JDK
      
    3. Grab a cup of coffee and you're done! You don't need to add the .exe to the java -version if everything is installed correctly.
    0 讨论(0)
  • 2020-12-02 17:08

    Open a command prompt:

     Version:  java -version
     Location: where java (in Windows)
               which java (in Unix, Linux, and Mac)
    

    To set Java home in Windows:

    Right click on My computerPropertiesAdvanced system settingsEnvironment VariableSystem VariableNew. Give the name as JAVA_HOME and the value as (e.g.) c:\programfiles\jdk

    Select Path and click Edit, and keep it in the beginning as: %JAVA_HOME%\bin;...remaining settings goes here

    0 讨论(0)
  • 2020-12-02 17:17
     System.out.println(System.getProperty("java.vendor"));
     System.out.println(System.getProperty("java.vendor.url"));
     System.out.println(System.getProperty("java.version"));
    
     Sun Microsystems Inc.
     http://java.sun.com/
     1.6.0_11
    

    http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html

    0 讨论(0)
  • 2020-12-02 17:17

    I had a problem where my Java applications quit work with no discernible evidence that I could find. It turned out my system started using the 64-bit version rather than the 32-bit version was needed (Windows Server 2012). In Windows, the command:

    Javaw -version
    

    just brought me back to the command prompt without any information. It wasn't until I tried

    Javaw -Version 2>x.txt
    type x.txt
    

    that it gave me what was being executed was the 64-bit version. It boiled down to my PATH environment variable finding the 64-bit version first.

    0 讨论(0)
  • 2020-12-02 17:19

    In Linux:

    java -version
    

    In Windows:

    java.exe -version
    

    If you need more info about the JVM you can call the executable with the parameter -XshowSettings:properties. It will show a lot of System Properties. These properties can also be accessed by means of the static method System.getProperty(String) in a Java class. As example this is an excerpt of some of the properties that can be obtained:

    $ java -XshowSettings:properties -version
    [...]
    java.specification.version = 1.7
    java.vendor = Oracle Corporation
    java.vendor.url = http://java.oracle.com/
    java.vendor.url.bug = http://bugreport.sun.com/bugreport/
    java.version = 1.7.0_95
    [...]
    

    So if you need to access any of these properties from Java code you can use:

    System.getProperty("java.specification.version");
    System.getProperty("java.vendor");
    System.getProperty("java.vendor.url");
    System.getProperty("java.version");
    

    Take into account that sometimes the vendor is not exposed as clear as Oracle or IBM. For example,

    $ java version
    "1.6.0_22" Java(TM) SE Runtime Environment (build 1.6.0_22-b04) Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
    

    HotSpot is what Oracle calls their implementation of the JVM. Check this list if the vendor does not seem to be shown with -version.

    0 讨论(0)
提交回复
热议问题