Как узнать версию jdk на windows

To get your jdk location in Windows, run this at a command prompt:

where java

This lists any and all locations of java.exe, including from your JAVA_HOME. For example, the 3rd line here reflects my JAVA_HOME location, where I’m pointing to JDK 8:

C:\Users\me> where java
C:\Program Files\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files\Java\jdk1.8.0_202\bin\java.exe

Note for comparison that java -version does not reflect my JAVA_HOME location and in fact shows java version 11 instead of 8:

C:\Users\me> java -version
java version "11.0.15" 2022-04-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.15+8-LTS-149)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.15+8-LTS-149, mixed mode)

This is confusing because my Java compiles (e.g., via mvn) use JDK 8 since that’s what my JAVA_HOME is pointing to. (I’m not even sure where the version 11 it found came from; possibly from when I installed maven.)

Determining the difference between the JRE and JDK you’re running has never been straightforward. Seems like java -version used to be a way to do this, but no longer.

Adding to the complexity, you can also supposedly get your Java version info from Control Panel > Programs > Java > About. For me, that shows Version 8. That’s despite java -version showing version 11.0.15. And it doesn’t change even if I point my JAVA_HOME to JDK 11.

Note that this answer is also helpful. In my case, that helped me determine that I have java.exe and javac.exe at C:\Program Files (x86)\Common Files\Oracle\Java\javapath and C:\Program Files\Common Files\Oracle\Java\javapath. Depending on which one I have listed first in my Path variable, I get different results when i run java -version or java --version. The former seems to work when Java 8 is listed first; the latter when Java 11 is first.

To get your jdk location in Windows, run this at a command prompt:

where java

This lists any and all locations of java.exe, including from your JAVA_HOME. For example, the 3rd line here reflects my JAVA_HOME location, where I’m pointing to JDK 8:

C:\Users\me> where java
C:\Program Files\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files\Java\jdk1.8.0_202\bin\java.exe

Note for comparison that java -version does not reflect my JAVA_HOME location and in fact shows java version 11 instead of 8:

C:\Users\me> java -version
java version "11.0.15" 2022-04-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.15+8-LTS-149)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.15+8-LTS-149, mixed mode)

This is confusing because my Java compiles (e.g., via mvn) use JDK 8 since that’s what my JAVA_HOME is pointing to. (I’m not even sure where the version 11 it found came from; possibly from when I installed maven.)

Determining the difference between the JRE and JDK you’re running has never been straightforward. Seems like java -version used to be a way to do this, but no longer.

Adding to the complexity, you can also supposedly get your Java version info from Control Panel > Programs > Java > About. For me, that shows Version 8. That’s despite java -version showing version 11.0.15. And it doesn’t change even if I point my JAVA_HOME to JDK 11.

Note that this answer is also helpful. In my case, that helped me determine that I have java.exe and javac.exe at C:\Program Files (x86)\Common Files\Oracle\Java\javapath and C:\Program Files\Common Files\Oracle\Java\javapath. Depending on which one I have listed first in my Path variable, I get different results when i run java -version or java --version. The former seems to work when Java 8 is listed first; the latter when Java 11 is first.

Комплект для разработки Java (JDK) содержит инструменты для разработки Java, а Среда выполнения Java (JRE) содержит JVM для преобразования байтового кода .class для машинного кода и его выполнения, короче говоря, JRE запускает программу Java.

Проверьте версию JDK Мы можем использовать java-версию чтобы узнать версию установленного JDK. В приведенном ниже примере версия JDK равна

$ javac -version

javac 11.0.7

Проверьте версию JRE Мы можем использовать java-версию , чтобы узнать версию установленной JRE. В приведенном ниже примере версия JRE равна 1.8.0_252

$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~19.10-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Версии JDK и JRE могут отличаться на одном компьютере. На одном компьютере разрешено несколько версий JDK и JRE; лучше выяснить, какая версия настроена в системном пути к классам для запуска или компиляции программы Java.

JDK также содержит JRE для запуска программы Java.

$JAVA_HOME/bin/java     <-- JDK
$JAVA_HOME/jre/bin/java <-- JRE

1.1 В Ubuntu или Linux мы можем использовать какой javac , чтобы узнать, где установлен JDK.

$ which javac
/usr/bin/javac

$ ls -lsah /usr/bin/javac
/usr/bin/javac -> /etc/alternatives/javac

$ ls -lsah /etc/alternatives/javac
/etc/alternatives/javac -> /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/bin/javac

$ cd /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/bin/
$ ./javac -version
javac 11.0.7

В приведенном выше примере JDK установлен по адресу /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/ .

1.2 В Windows мы можем использовать где javac , чтобы узнать, где установлен JDK.

Microsoft Windows [Version 10.0.18362.900]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\mkyong>which javac
'which' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\mkyong>where javac
C:\opt\jdk-11.0.1\bin\javac.exe

Нужен ли мне JDK или JRE? Для конечных пользователей им необходимо установить JRE для запуска программы Java, а JDK предназначен для разработчиков. В производственной среде команде развертывания необходимо установить JRE только для запуска программы Java. Однако разработчики часто запрашивают установку JDK вместо автономной JRE на рабочем сервере, поскольку JDK содержит JRE, а также дополнительные инструменты для мониторинга и отладки запущенной Java-программы.

Рекомендации

  • Википедия – Набор для разработки Java (JDK)
  • Википедия – Виртуальная машина Java
  • Как установить Java JDK на Ubuntu

Оригинал: “https://mkyong.com/java/how-to-check-current-java-version-installed-in-your-computer/”



  • Метки



    computer, jre, terminal, version

To totally unlock this section you need to Log-in

Firts of all, for end-users, they need to install JRE to run the Java program, and the JDK is for developers. For the production environment, the deployment team only need to install JRE to run the Java program. However, developers often request to install the JDK, instead of the standalone JRE on the production server, because the JDK contains JRE and also extra tools to monitor and debug the running Java program.

The Java development kit (JDK) contains tools for Java development, and the Java Runtime Environment (JRE) contains a JVM to convert byte code .class to machine code, and execute it, in short, the JRE runs Java program.

A common way to check JDK version is by using the following simple command to find out the version of the installed JDK. In the below example, the JDK version is 11.0.7:

$ javac -version
javac 11.0.7

Check JRE Version

Similarly, we can use java -version to find out the version of the installed JRE. In the below example, the JRE version is 1.8.0_252:

$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~19.10-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

The JDK and JRE versions can be different on the same computer. Multiple JDK and JRE versions are allowed on the same computer; it is better to find out which version is configured in the system classpath to run or compile the Java program.

Where JDK is installed?

On Ubuntu or Linux system, we can use which javac to find out where JDK is installed:

$ which javac
/usr/bin/javac

$ ls -lsah /usr/bin/javac
/usr/bin/javac -> /etc/alternatives/javac

$ ls -lsah /etc/alternatives/javac
/etc/alternatives/javac -> /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/bin/javac

$ cd /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/bin/
$ ./javac -version
javac 11.0.7

In the above example, the JDK is installed at /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/.

In addition, we can use Linux apt package manager (Debian/Ubuntu systems) to get info about installed Java:

sudo apt list --installed | grep -i openjdk

We can also list all installed packages and filter for Java using the dpkg command:

dpkg -l | grep -i openjdk

And below on RedHat/CentOS systems (obviously the java -version approach is still valid):

rpm -qi openjdk

OR

yum info "openjdk"

OR

yum list installed | grep -i openjdk

On Microsoft Windows, we can use dir /b /s javac.exe to find out where JDK is installed.

Microsoft Windows [Version 10.0.18362.900]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\>dir /b /s javac.exe
C:\Program Files\Common Files\Oracle\Java\javapath\javac.exe
C:\Program Files\Common Files\Oracle\Java\javapath_target_52887656\javac.exe
C:\Program Files\Java\jdk-11.0.12\bin\javac.exe
C:\Program Files\Java\jdk1.8.0_271\bin\javac.exe

Or, alternatively, using Powershell:

Get-Childitem –Path C:\ -Include javac.exe -Recurse -ErrorAction SilentlyContinue

Check Java Version in Windows 10 (GUI)

You can get the version number of Java installed on your computer if you enter java in Windows 10 search box and run Java applet.

Java (JRE/JDK) - Check version installed (Classic and Powershell methods)

In About Java window, the current JRE version is specified. In this case, it is Java Version 8 Update 261 (build 1.8.0_261-b12). Note the value of the JRE build. All Java versions have 1 at the beginning followed by the number of major JRE version (it is 8 in this case) and the update number.

Java (JRE/JDK) - Check version installed (Classic and Powershell methods)

We can also check the current Java version in Windows Program and Features (Win+R -> appwiz.cpl).

Java (JRE/JDK) - Check version installed (Classic and Powershell methods)

Check Java Version using PowerShell

You can check Java version installed on your computer using PowerShell. You can just check the version of the executable file java.exe (the path to it is set in the environment variables when JRE SE is installed on your computer). Display the java file version:

Get-Command Java | Select-Object Version

Java (JRE/JDK) - Check version installed (Classic and Powershell methods)

We can view detailed information about Java version, update and release number:

Get-Command java | Select-Object -ExpandProperty Version

Major Minor Build Revision
----- ----- ----- --------
8 0 2610 12

If we want to get a string value of your Java JRE version to be used in scripts, use the command:

(Get-Command java | Select-Object -ExpandProperty Version).tostring()

Java (JRE/JDK) - Check version installed (Classic and Powershell methods)

If we want to specifically be sureabout the JDK version installed on the system, we can use the following Powershell command targeting the Java compiler, javac.exe:

(Get-Command javac | Select-Object -ExpandProperty Version).tostring()

We can also find out your Java version using WMI class Win32_Product (contains the list of installed programs in Windows):

Get-WmiObject -Class Win32_Product -Filter "Name like '%Java%'"

Java (JRE/JDK) - Check version installed (Classic and Powershell methods)

The IDs may be used later to correctly uninstall JRE.

If you want to display only Java version without Java Auto Updater, use the following command:

Get-WmiObject -Class Win32_Product -Filter "Name like '%Java%' and not Name like '%Java Auto Updater%'" | Select -Expand Version

Finally, we can dig directly into the Windows Registry, using Powershell, to get the actual installed version of both JRE and JDK packages with the following two commands:

dir "HKLM:\SOFTWARE\JavaSoft\Java Runtime Environment"  | select -ExpandProperty pschildname -Last 1
dir "HKLM:\SOFTWARE\JavaSoft\Java Development Kit"  | select -ExpandProperty pschildname -Last 1

Check Java Version on Remote Computers (Powershell)

If we want to get Java versions used on all computers or servers in your domain, you can use the following PowerShell script. The script can get the information from all servers remotely according to the list you enter manually or from a text file. You can also get the list of servers or computers in AD using the Get-ADComputer cmdlet from the RSAT-AD-PowerShell module.

# Check Java version against the list of servers in a text file
#$computers=Get-content C:\PS\ServerList.txt

# To get Java version on all Windows Servers in AD domain
$computers = ((get-adcomputer -Filter { enabled -eq “true” -and OperatingSystem -Like ‘*Windows Server*’ }).name).tostring()
Get-WmiObject  -Class Win32_Product -ComputerName $computers -Filter “Name like ‘%Java%’ and not Name like ‘%Java Auto Updater%'” | Select __Server, Version

An additional, similar, way to get Java version info from remote systems, by using Powershell, is the following Invoke-Command approach:

$Servers = Get-Content 'C:\Server.txt'
$ServersNotAvailable = @()
$JavaVersion = {
    function GetJavaVersion()
    {
    Try {
        $ret = java -version 2>&1 | Select-String "version" | select @{n="Server";e={$env:COMPUTERNAME}},@{n="JavaVersion";e={$_.Line}}
        return $ret
        }
    Catch {
    $Prop = [ordered]@{Server = $env:COMPUTERNAME
                       JavaVersion = "Java Not Available"
                       }
    New-Object -TypeName psobject -Property $Prop
           }
    }
    GetJavaVersion
}
foreach($Server in $Servers) {
          $TestCon = Test-Connection -ComputerName $Server -Count 1 -Quiet
          if($TestCon) {
               Invoke-Command -ComputerName $Server -ScriptBlock $javaversion | Select Server,JavaVersion
          }
          else {
               $ServersNotAvailable = $Server + "," + $ServersNotAvailable
          }
}
### Below is list of servers which are not available over the network or not pingable
Write-Host "`nServers Not reachable over Network" -ForegroundColor Green
$ServersNotAvailable

Summary

Article Name

Java (JRE/JDK) — Check version installed

Description

The Java development kit (JDK) contains tools for Java development, and the Java Runtime Environment (JRE) contains a JVM to convert byte code .class to machine code, and execute it, in short, the JRE runs Java program. In this this article we will see different methods to check which version is installed on a Linux/Windows system.

Author

Publisher Name

Heelpbook.net

Java is a programming language that is platform-independent, popular, simple, secure, and statically typed. Before discussing let’s clear Java language needs a runtime platform so before going ahead let’s clear how java is present on the machine.

Java language comprises three components mainly:

  • Java Development Kit
  • Java Runtime Environment
  • Java Virtual Machine 
     

Runtime Concepts than only we will check whether Java is there on the Platform (Operating System + Architecture)

1. Java Virtual Machine

This is a machinespecific software which is responsible for byte code on that machine and converts it into machine-specific instructions.

JVM is different for Windows 
JVM is different for Linux
JVM is different for Different Platforms

So as a programmer we don’t need to check presence on the machine as it is pre-installed in the machine. It is responsible for running Java code line by line.

2. Java Runtime Environment

It is simply a package that provides an environment to only run our java code on the machine. No development takes place here because of the absence of developmental tools.

3. Java Development Kit 

It is also a package that provides an environment to develop and execute where JRE is a part of it along with developmental tools.

  • JDK = JRE + Developmental Tools
  • JRE = JVM + Library Classes

Now, The first and Foremost step is to check the Java Development Kit in Windows which is also known as JDK. There are lots of versions of Java. Depending upon the operating system methods there are several methods to find the version of Installed JAVA on your Machine:

Let us discuss 3 standard methods in Windows

  1. User needs to open Command Prompt and enter- ‘java -version’
  2. Open control panel and lookup for Java
  3. Directories method- Click the Menu ‘Start’ and typing About.java or readme file

Taking one by one, showcasing in-depth individually

1. Command Prompt

The CMD (Command Interpreter is a command-line Interface. It supports a set of commands and utilities; and has its own programming language for writing batch files. Open CMD and search java -version. First, we have to an environment variable to the installed path location of the java folder. Otherwise, it will show invalid command. It is called ‘Terminal’ in the case of mac operating systems.

java -version  // CMD/Terminal command to check java version on the machine

In the case of Windows OS: It is showing java is installed on the machine with version 1.8.0 (See carefully at line number 5)

“1.8.0_144”  is the version of the java

In the case of macOS: It is showing java is installed on the machine with version 14.0.1 ( see carefully at line number 2)

Second Method: 

  • Open Control Panel and there is an option of the java on the interface of the control panel
  • Click on the java option and click about a small pop window will appear

In the case of Windows:

In the case of Mac: Click on the Java icon downside. System preferences in mac are the same as the Control panel in Windows. 

Third Method:

Search Program and features in the control panel and search JAVA Named option

In the case of Windows: Simply custom search- About Java

In the case of Mac: 

Press the command button followed by a spacebar without lifting fingers from the command button.

A popup box will appear for less than a second followed by another pop-up as shown below:

Last Updated :
29 Oct, 2020

Like Article

Save Article

  • Как узнать версию hdmi кабеля windows 10
  • Как узнать адрес ldap сервера windows
  • Как узнать адрес ipv4 windows 7
  • Как узнать админский пароль windows 10
  • Как узнать x64 или x86 windows 10