- How do I find Java version?
- Using System Properties
- Using Runtime.version()
- Как определить версию Java
- Проверка онлайн
- Windows
- How do I find Java version?
- Using System Properties
- Using Runtime.version()
- Rfr epyfnm dthcb java
- Learn Latest Tutorials
- Preparation
- Trending Technologies
- B.Tech / MCA
- Javatpoint Services
- Training For College Campus
How do I find Java version?
The simplest way to get the Java version is by running the java -version command in your terminal application or Windows command prompt. If Java is installed and available on your path you can get information like below.
java -version java version "17" 2021-09-14 LTS Java(TM) SE Runtime Environment (build 17+35-LTS-2724) Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
Using System Properties
But if you want to get Java version from your Java class or application you can obtain the Java version by calling the System.getProperty() method and provide the property key as argument. Here are some property keys that related to Java version that you can read from the system properties.
package org.kodejava.lang; public class JavaVersion < public static void main(String[] args) < String version = System.getProperty("java.version"); String versionDate = System.getProperty("java.version.date"); String runtimeVersion = System.getProperty("java.runtime.version"); String vmVersion = System.getProperty("java.vm.version"); String classVersion = System.getProperty("java.class.version"); String specificationVersion = System.getProperty("java.specification.version"); String vmSpecificationVersion = System.getProperty("java.vm.specification.version"); System.out.println("java.version: " + version); System.out.println("java.version.date: " + versionDate); System.out.println("java.runtime.version: " + runtimeVersion); System.out.println("java.vm.version: " + vmVersion); System.out.println("java.class.version: " + classVersion); System.out.println("java.specification.version: " + specificationVersion); System.out.println("java.vm.specification.version: " + vmSpecificationVersion); >>
Running the code above give you output like the following:
java.version: 17 java.version.date: 2021-09-14 java.runtime.version: 17+35-LTS-2724 java.vm.version: 17+35-LTS-2724 java.class.version: 61.0 java.specification.version: 17 java.vm.specification.version: 17
Using Runtime.version()
Since JDK 9 we can use Runtime.version() to get Java runtime version. The feature() , interim() , update and patch() methods of the Runtime.Version class are added in JDK 10. These methods is a replacement for the major() , minor() and security() methods of JDK 9.
Below is the code snippet that demonstrate the Runtime.version() .
package org.kodejava.lang; public class RuntimeVersion < public static void main(String[] args) < System.out.println("Version: " + Runtime.version()); System.out.println("Feature: " + Runtime.version().feature()); System.out.println("Interim: " + Runtime.version().interim()); System.out.println("Update: " + Runtime.version().update()); System.out.println("Patch: " + Runtime.version().patch()); System.out.println("Pre: " + Runtime.version().pre().orElse("")); System.out.println("Build: " + Runtime.version().build().orElse(null)); System.out.println("Optional: " + Runtime.version().optional().orElse("")); >>
Running the code snippet above produce the following output:
Version: 17+35-LTS-2724 Feature: 17 Interim: 0 Update: 0 Patch: 0 Pre: Build: 35 Optional: LTS-2724
Here are the summary of outputs running the above code using some JDKs installed on my machine.
Version | Feature | Interim | Update | Patch | Pre | Build | Optional |
---|---|---|---|---|---|---|---|
10.0.2+13 | 10 | 0 | 2 | 0 | 13 | ||
11.0.6+8-LTS | 11 | 0 | 6 | 0 | 8 | LTS | |
12.0.2+10 | 12 | 0 | 2 | 0 | 10 | ||
13.0.2+8 | 13 | 0 | 2 | 0 | 8 | ||
14+36-1461 | 14 | 0 | 0 | 0 | 36 | 1461 | |
15.0.2+7-27 | 15 | 0 | 2 | 0 | 7 | 27 | |
17+35-LTS-2724 | 17 | 0 | 0 | 0 | 35 | LTS-2724 |
A programmer, recreational runner and diver, live in the island of Bali, Indonesia. Programming in Java, Spring, Hibernate / JPA. You can support me working on this project, buy me a cup of coffee ☕ every little bit helps, thank you 🙏
Как определить версию Java
wikiHow работает по принципу вики, а это значит, что многие наши статьи написаны несколькими авторами. При создании этой статьи над ее редактированием и улучшением работали, в том числе анонимно, 12 человек(а).
Количество просмотров этой статьи: 86 575.
На одном компьютере может быть установлено несколько копий Java, и, если у вас несколько браузеров, каждый из них может использовать свою версию или не использовать вовсе. В этой статье описано несколько способов, как это проверить.
Проверка онлайн
Откройте новое окно в вашем браузере и кликните сюда для перехода на сайт Java. Oracle, разработчик платформы Java, создал простую страницу, которая проверяет установленную у вас Java и сообщает точную версию. Это можно сделать из любой операционной системы.
При появлении запроса от программы безопасности вашего браузера, позвольте Java подтвердить версию.
Через несколько секунд проверьте результаты! Они будут включать номер версии и номер обновления. Номер версии наиболее важен, если вы проверяете на совместимость с другими программами.
Windows
Нажмите сочетание клавиш windows + r и введите «cmd» и в открывшейся командной строке введите java -version. Результат будет выглядеть примерно так: Java version «1.6.0_03 Java(TM) SE Runtime Environment (build 1.6.0_03-b05) Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing).
На компьютере, на котором не установлена ни одна из версий Java от Sun Microsystems, это приведет к сообщению об ошибке: ‘java’ is not recognized as an internal or external command, operable program or batch file (‘Java’ не распознается как внутренняя или внешняя команда, исполняемая программа или пакетный файл).
На компьютере, на котором установлена только очень старая версия Java от Microsoft, будет такое же сообщение об ошибке. На машине с несколькими версиями Java эта команда вернет версию JVM по умолчанию.
How do I find Java version?
The simplest way to get the Java version is by running the java -version command in your terminal application or Windows command prompt. If Java is installed and available on your path you can get information like below.
java -version java version "17" 2021-09-14 LTS Java(TM) SE Runtime Environment (build 17+35-LTS-2724) Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
Using System Properties
But if you want to get Java version from your Java class or application you can obtain the Java version by calling the System.getProperty() method and provide the property key as argument. Here are some property keys that related to Java version that you can read from the system properties.
package org.kodejava.lang; public class JavaVersion < public static void main(String[] args) < String version = System.getProperty("java.version"); String versionDate = System.getProperty("java.version.date"); String runtimeVersion = System.getProperty("java.runtime.version"); String vmVersion = System.getProperty("java.vm.version"); String classVersion = System.getProperty("java.class.version"); String specificationVersion = System.getProperty("java.specification.version"); String vmSpecificationVersion = System.getProperty("java.vm.specification.version"); System.out.println("java.version: " + version); System.out.println("java.version.date: " + versionDate); System.out.println("java.runtime.version: " + runtimeVersion); System.out.println("java.vm.version: " + vmVersion); System.out.println("java.class.version: " + classVersion); System.out.println("java.specification.version: " + specificationVersion); System.out.println("java.vm.specification.version: " + vmSpecificationVersion); >>
Running the code above give you output like the following:
java.version: 17 java.version.date: 2021-09-14 java.runtime.version: 17+35-LTS-2724 java.vm.version: 17+35-LTS-2724 java.class.version: 61.0 java.specification.version: 17 java.vm.specification.version: 17
Using Runtime.version()
Since JDK 9 we can use Runtime.version() to get Java runtime version. The feature() , interim() , update and patch() methods of the Runtime.Version class are added in JDK 10. These methods is a replacement for the major() , minor() and security() methods of JDK 9.
Below is the code snippet that demonstrate the Runtime.version() .
package org.kodejava.lang; public class RuntimeVersion < public static void main(String[] args) < System.out.println("Version: " + Runtime.version()); System.out.println("Feature: " + Runtime.version().feature()); System.out.println("Interim: " + Runtime.version().interim()); System.out.println("Update: " + Runtime.version().update()); System.out.println("Patch: " + Runtime.version().patch()); System.out.println("Pre: " + Runtime.version().pre().orElse("")); System.out.println("Build: " + Runtime.version().build().orElse(null)); System.out.println("Optional: " + Runtime.version().optional().orElse("")); >>
Running the code snippet above produce the following output:
Version: 17+35-LTS-2724 Feature: 17 Interim: 0 Update: 0 Patch: 0 Pre: Build: 35 Optional: LTS-2724
Here are the summary of outputs running the above code using some JDKs installed on my machine.
Version | Feature | Interim | Update | Patch | Pre | Build | Optional |
---|---|---|---|---|---|---|---|
10.0.2+13 | 10 | 0 | 2 | 0 | 13 | ||
11.0.6+8-LTS | 11 | 0 | 6 | 0 | 8 | LTS | |
12.0.2+10 | 12 | 0 | 2 | 0 | 10 | ||
13.0.2+8 | 13 | 0 | 2 | 0 | 8 | ||
14+36-1461 | 14 | 0 | 0 | 0 | 36 | 1461 | |
15.0.2+7-27 | 15 | 0 | 2 | 0 | 7 | 27 | |
17+35-LTS-2724 | 17 | 0 | 0 | 0 | 35 | LTS-2724 |
A programmer, recreational runner and diver, live in the island of Bali, Indonesia. Programming in Java, Spring, Hibernate / JPA. You can support me working on this project, buy me a cup of coffee ☕ every little bit helps, thank you 🙏
Rfr epyfnm dthcb java
Learn Latest Tutorials
Preparation
Trending Technologies
B.Tech / MCA
Javatpoint Services
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
- Website Designing
- Website Development
- Java Development
- PHP Development
- WordPress
- Graphic Designing
- Logo
- Digital Marketing
- On Page and Off Page SEO
- PPC
- Content Development
- Corporate Training
- Classroom and Online Training
- Data Entry
Training For College Campus
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week
Like/Subscribe us for latest updates or newsletter