How to know java version

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
Читайте также:  Html pattern только буквы

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 🙏

Источник

How to Check Java Version on Mac or Windows

Java runs many of the applications that we use daily. Many applications cannot run on older versions of Java. Hence, it is essential to know which version is installed on your system.

In this tutorial, learn how to check the Java version on your Mac or Windows system.

How to Check if Java is Installed and version on mac or windows

  • A system running macOS or Windows
  • Access to the command-line/terminal window
  • A version of Java installed

Check Java Version on Mac

You can find the version of Java on macOS by:

  • using the GUI (Mac’s System Preferences)
  • prompting for the version in the terminal window

Option 1: Check Java Version on Mac Using the GUI

To check the Java version on Mac without using the terminal by searching for the Java Control Panel in the System Preferences.

1. Click the Apple icon in the menu bar to open the drop-down menu and navigate to System Preferences.

Finding system preferences on Mac

2. A new window opens with various icons and settings. Find and click the Java icon to open the Java Control Panel.

Opening the Java control panel on Mac os

3. Once the Java Control Panel opens, click the About button. A new window with Java version information should appear.

Finding the Java version on macOS from the system preferences

Option 2: Check Java Version on Mac Using the Terminal

If you prefer using the terminal, checking the Java version is a simple one-command process.

1. First, open the terminal. To do so, click the Spotlight Search button in the top-right of the screen.

Mac spotlight search button.

2. Type terminal in the search bar and open it by clicking on the icon in the search results.

Open terminal on Mac.

3. Once in the command line, run the command: java -version . The output should display the Java version installed on your MacOS.

java version 1.8.0_261 installed on macOS

To check the version of the primary Java compiler – javac (pronounced “java-see”) use the command:

Note: If you have a Linux system, refer to How To Check Java Version Installed On Linux.

Check Java Version on Windows

To check the Java version on a Windows computer, you can use:

Option 1: Check Java Version on Windows Using GUI

To find the Java version on your Windows without opening a terminal window, use the Control Panel.

1. Open the Windows menu in the bottom-left corner and type control panel in the search bar.

Searching for the control panel in the Windows start menu.

2. Find the Control Panel in the search results and click the icon to open it.

Opening the control panel on Windows

3. Move to the Programs directory.

Читайте также:  Java project into exe

screenshot of the Open programs directory in Windows

4. Find and click the Java icon to open the Java Control Panel.

example of opening the Java Control Panel

5. Once the control panel opens, click the About button.

Viewing information about the Java control panel

6. The About Java window should appear and display the Java version on your computer.

example output of java version 8 update 261 installed on windows

Option 2: Check Java Version on Windows Using Command Line

Another option to find the Java version on Windows is through the command line.

1. Open the Windows Start menu in the bottom-left corner and type cmd in the search bar.

Search for command prompt on Windows

2. Then, open the Command Prompt once it appears in the search results.

Open command prompt on Windows

3. A new window with the command prompt should appear. In it, type the command java -version and hit Enter. The output should display the Java version installed on your Windows system.

java version 1.8.0_261 installed on windows

You can also check the version of the Java’s primary compiler, javac, with the command:

This article showed you how to check the version of Java installed on a macOS or Windows system.

Источник

How to Check Java Version

In today’s blog, we will be showing you how to check the Java version on Windows and macOS operating systems.

How to Check Java Version

List of content you will read in this article:

Among all the programming languages, Java is considered to be the most commonly used language that has been adopted worldwide. There are numerous reasons why Java has gained popularity over other alternatives. There is no doubt that Java has been famous among all Fortune 500 companies and is widely recommended by developers. Its user-friendly and flexible nature makes it a go-to programming language for web developers and programmers.

The main reasons behind Java being popular is its fast speed, high-end security, and reliability. Along with such benefits, Java also offers private transmission, automatic memory management, and secure crucial information.

About Java

Introduced in the 1990s by James Gosling, Java is an object-oriented, robust, and secure programming language. The team started this Java project to develop a language suitable, especially for digital devices like set-top boxes, television, etc. At first, C++ was to be used in the Java project but was not considered for some reasons. Later, Gosling expanded C++ and led to another stage of a project Green, which was later renamed the ‘Greentalk’ project by Gosling and his team members. These project files had the file extension as .gt, which is later recognized as ‘OAK.’

The name ‘OAK’ was given to the project after an oak tree that was located outside Gosling’s office. But later on, the term ‘OAK’ was changed to Java. After various talks and brainstorming sessions, Gosling and his team come to multiple names- JAVA, DNA, SILK, BURY, etc. Still, they decided on JAVA after many discussions due to its uniqueness. This name (Java) comes up from a type of espresso bean. Gosling and his team members had come up with this name while having a cup of coffee near their office.

Читайте также:  Php multi query mysql

The main principles on which Java was built are- robust, portable, platform-independent, multi-thread, etc. In 1995, Java was recognized as one of the ten best products in Time magazine. Today, Java has been used in various fields like internet programming, mobile devices, games, etc. later, multiple versions of Java have been introduced over the years with new added features and functionalities.

Versions of Java

Over time, Java has introduced various versions with different and advanced features than the earlier version. Every version has fulfilled the drawback of their previous versions. Some of the versions are still supported, and some of them are not. Below is the list of all the Java versions introduced to date.

Support Until

Источник

Как узнать версию Java в Windows 10

Как узнать версию Java на Windows 10

Получить базовые сведения об установленной платформе Java можно непосредственно из ее интерфейса, а именно – из панели управления Java.

  1. Откройте панель управления Java через поиск Windows или классическую «Панель управления». Как узнать версию Java на Windows 10-1
  2. В открывшемся окне панели нажмите «About…». Как узнать версию Java на Windows 10-2
  3. Появится окошко, в котором будет указана версия и сборка платформы. Как узнать версию Java на Windows 10-3

Способ 2: Консоль «PowerShell»

Удобно для получения номера версии и сборки Java использовать встроенную консоль «PowerShell».

Как узнать версию Java на Windows 10-4

  • Выполните в открывшейся консоли команду Get-Command Java | Select-Object Version . Существует и более информативный вариант команды – Get-Command java | Select-Object -ExpandProperty Version . Как узнать версию Java на Windows 10-5
  • В результате в консоль будут выведены номер версии, обновления, сборки и ревизии.

    Способ 3: Командная строка

    В классической «Командной строке» команда получения номера версии платформы Java еще проще, чем в «PowerShell», но здесь есть один нюанс.

      Откройте «Командную строку» от имени администратора из поиска Windows или другим известным способом.

    Как узнать версию Java на Windows 10-6

  • Выполните команду java -version . Как узнать версию Java на Windows 10-7
  • Обратите внимание на формат вывода: номер версии указывается второй цифрой, вначале идет 1 независимо от версии. Например, результат «1.8.0_331» станет означать, что на компьютере установлена версия платформы 8.0, сборка 331.

    Способ 4: Панель управления

    Номер версии и сборки также указан в окне апплета «Программы и компоненты», там же указывается название поставщика и дата установки платформы.

    Как узнать версию Java на Windows 10-8

  • Найдите в списке элемент «Java» и посмотрите версию и номер сборки. Как узнать версию Java на Windows 10-9
  • Способ 5: Проводник

    Как узнать версию Java на Windows 10-10

    Наконец, узнать номер версии и сборки платформы можно с помощью обычного «Проводника». Если пользователь не менял путь установки, папку Java можно будет найти в расположении C:\Program Files\Java .

    В этом каталоге располагается папка с файлами установки, в названии которой указывается номер версии и сборки в том же формате, в котором их выводит «Командная строка», смотрите Способ 3.

    Источник

    Оцените статью