OpenJDK (Open Java Development Kit) is a free and open-source implementation of the Java Platform, Standard Edition (Java SE).
OpenJDK 11 for Windows provides a distribution of OpenJDK that follows the Red Hat Enterprise Linux distribution of OpenJDK as closely as possible on the Microsoft Windows platform.
Windows builds use Red Hat Enterprise Linux RPM sources and apply all of the relevant RPM patches.
OpenJDK 11 for Windows includes OpenJDK, fonts, timezone data, and CA certificates from Red Hat Enterprise Linux.
1. Installing OpenJDK on Windows
1.1. Installing OpenJDK using the zip bundle
The easiest way to install the JDK on Windows is to unarchive the zip via the command prompt.
Note |
Extracting the contents of the zip bundle to a directory path that does not contain spaces is recommended. This is important as many scripts that reference the |
Procedure
-
Download the zip bundle of OpenJDK 11 for Windows.
-
Extract the contents of the zip bundle to a directory of your choice. See the note and caution above about spaces in the install path.
-
Update the
PATH
as below:C:> setx /m PATH "%PATH%;<YOUR_INSTALL_PATH>bin"
Note
The above command only works if you start the command prompt with
Run as administrator
./m updates the value as a system wide setting, instead of the default local environment.
You have to restart the command prompt to check the setting by typing
path
. -
Verify the OpenJDK 11 for Windows is installed by running:
java -version
in a newly opened command prompt and you should see the following:java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode) or openjdk version "1.8.0_212-2-redhat" OpenJDK Runtime Environment (build 1.8.0_212-2-redhat-b04) OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode) or openjdk version "11.0.3-redhat" 2019-04-16 LTS OpenJDK Runtime Environment 18.9 (build 11.0.3-redhat+7-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.3-redhat+7-LTS, mixed mode)
-
The
%JAVA_HOME%
environment variable must also be set to use some developer tools.Set the
%JAVA_HOME%
environment variable asC:> setx /m JAVA_HOME "<YOUR_INSTALL_PATH>"
Note
JAVA_HOME
will not work if thebin
directory is appended to your installation path.After restarting the command prompt, you can view your setting by typing
echo %JAVA_HOME%
. -
Open Command Prompt as an administrator.
-
Set the value of the environment variable to your OpenJDK installation path:
C:> setx /m JAVA_HOME "C:Progra~1RedHatjava-11-openjdk-11.0.1.13-1"
If the path contains spaces, use the shortened path name.
-
Restart Command Prompt to reload the environment variables.
1.2. Installing OpenJDK with the MSI Installer
The simplest way to install OpenJDK on Microsoft Windows.
Procedure
-
Download the MSI-based installer for OpenJDK 11 for Windows.
-
Run the installer for OpenJDK 11 for Windows.
-
Click
Next
on the Welcome Screen -
Check
I accept the terms in the License Agreement
, then clickNext
-
Click
Next
and accept the defaults, review the optional properties below if you wish to make changes. -
Click
Install
-
Click
Yes
on, «Do you want to allow this app to make changes to your device?». -
Verify the OpenJDK 11 for Windows is installed by running:
java -version
in a newly opened Command Prompt and you should see the following:java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode) or openjdk version "1.8.0_212-2-redhat" OpenJDK Runtime Environment (build 1.8.0_212-2-redhat-b04) OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode) or openjdk version "11.0.3-redhat" 2019-04-16 LTS OpenJDK Runtime Environment 18.9 (build 11.0.3-redhat+7-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.3-redhat+7-LTS, mixed mode)
(Optional)
Select the desired extra environment settings if needed as described below
The OpenJDK 11 for Windows MSI-based installer includes the following components and sets the following properties:
Components
- JDK Files
-
Java Development Kit (JDK) OpenJDK 11 for Windows files.
Properties
Setting | Default | JDK 8 | JDK 11 | Description |
---|---|---|---|---|
OpenJDK Runtime — Windows Registry |
Yes |
Yes |
Yes |
The following registry keys are set HKLMSoftwareJavaSoftJDK, entries: |
OpenJDK Runtime — Path Variable |
Yes |
Yes |
Yes |
Adds the Runtime to the Path variable so it is available from the command line. |
OpenJDK Runtime — JAVA_HOME System Variable |
No |
Yes |
Yes |
JAVA_HOME is used by some programs to find the Java runtime. |
OpenJDK Runtime — REDHAT_JAVA_HOME System Variable |
No |
Yes |
Yes |
REDHAT_JAVA_HOME will be used in the future for Mission Control. |
OpenJDK Runtime — Jar Files Association |
No |
Yes |
Yes |
This enables Jar files to be run from within Windows Explorer. |
Web Start (Beta) — JNLP File Association |
No |
Yes |
No |
Enables the launching of JNLP files downloaded from the web. |
Web Start (Beta) — PATH Variable |
No |
Yes |
No |
Enables the launching of JNLP files downloaded from the web from the local file system. |
Web Start (Beta) — Keep Settings and Cache |
No |
Yes |
No |
Keeps settings and caches on the local file system. |
Mission Control — Path Variable |
No |
No |
Yes |
Adds Mission Control to the Path Variable so it is available from the command line. |
2. Updating OpenJDK on Windows
2.1. Updating OpenJDK for Microsoft Windows using the zip bundle
OpenJDK 11 for Windows can be manually update using the zip bundle.
Procedure
-
Download the ZIP bundle of 11.0.3.
-
Extract the contents of the ZIP bundle to a directory of your choice.
Note
Extracting the contents of the zip bundle to a directory path that does not contain spaces is recommended.
-
On the command prompt, update
JAVA_HOME
environment variable as follows: -
Open Command Prompt as an administrator.
-
Set the value of the environment variable to your OpenJDK installation path:
C:> setx /m JAVA_HOME "C:Progra~1RedHatjava-11-openjdk-11.0.1.13-1"
If the path contains spaces, use the shortened path name.
-
Restart Command Prompt to reload the environment variables.
-
Set the value of path variable if it is not set already:
C:> setx -m PATH "%PATH%;%JAVA_HOME%bin";
-
Restart the command prompt to reload the environment variables.
-
Verify that
java -version
works without supplying the full path.C:> java -version openjdk version "11.0.3" 2019-04-16 LTS OpenJDK Runtime Environment (build 11.0.3+7-LTS) OpenJDK 64-bit Server VM (build 11.0.3+7-LTS, mixed mode)
3. Configuring OpenJDK for Windows
3.1. Selecting a specific JDK from the installed versions for an application
You can select a specific JDK from the installed versions on Microsoft Windows for an application.
Prerequisites
-
More than one JDK is already installed on the system.
Procedure
-
Log in as a Windows system administrator.
-
On the command line, set the prompt to
C:/
. -
Enter
dir /b /s java.exe
to list all of the installed JDKs on the system. -
Set the value of the environment variable to your JDK (or JRE) installation path:
setx -m JAVA_HOME "Path to Java"
If the path contains spaces, use the shortened path name.
-
Restart the command prompt to reload the environment variables.
-
Retrieve the value of the path variable:
-
Set the value of path variable:
setx -m PATH "%PATH%;%JAVA_HOME%bin";
3.2. Setting up JDK Mission Control for Windows
This procedure describes how to install and set up JDK Mission Control for Microsoft Windows.
Prerequisites
-
Installation of OpenJDK 11 for Microsoft Windows.
Procedure
-
Unarchive the zip
-
In the
missioncontrol
directory, open the JMC client executable file. -
On the command line, start the JMC Client by entering
jmc
or the the full path to the JMC executable.JAVA_HOMEmissioncontroljmc.exe
-
On the JMC Client screen, create a new connection from the File Menu, choose your JVM, and start JMX console.
-
The result should give you an overview page with Processors, Memory consumption, Java heap use, JVM CPU usage, etc.
3.3. Configuring OpenJDK to run with customized heap size
OpenJDK 11 for Windows can be configured to use a customized heap size.
Prequisites
-
Installed Java Runtime
Procedure
-
Run the application by adding maximum heap size option to your java command line. For example to set the maximum heap size to 100 megabytes use the
-Xmx100m
option.$ java -Xmx100m
<your-main-class>
Revised on 2019-06-04 11:00:20 EDT
In the past, Oracle used to publish an executable installers for Windows that would:
- Unpack files
- Add registry keys indicating the installed version and path
- Add the JRE to the system PATH
- Register an uninstaller with Windows.
As of Java 11, the Oracle’s free version of Java (Oracle OpenJDK) doesn’t seem to include an installer. It is just a zip file containing the binaries.
How are we supposed to install OpenJDK 11 on Windows seeing as the aforementioned integrations are no longer there? Aren’t they necessary?
asked Sep 26, 2018 at 7:01
GiliGili
84.3k94 gold badges382 silver badges680 bronze badges
17
-
Extract the zip file into a folder, e.g.
C:Program FilesJava
and it will create ajdk-11
folder (where the bin folder is a direct sub-folder). You may need Administrator privileges to extract the zip file to this location. -
Set a PATH:
- Select Control Panel and then System.
- Click Advanced and then Environment Variables.
- Add the location of the bin folder of the JDK installation to the PATH variable in System Variables.
- The following is a typical value for the PATH variable:
C:WINDOWSsystem32;C:WINDOWS;"C:Program FilesJavajdk-11bin"
-
Set JAVA_HOME:
- Under System Variables, click New.
- Enter the variable name as JAVA_HOME.
- Enter the variable value as the installation path of the JDK (without the
bin
sub-folder). - Click OK.
- Click Apply Changes.
- Configure the JDK in your IDE (e.g. IntelliJ or Eclipse).
You are set.
To see if it worked, open up the Command Prompt and type java -version
and see if it prints your newly installed JDK.
If you want to uninstall — just undo the above steps.
Note: You can also point JAVA_HOME
to the folder of your JDK installations and then set the PATH
variable to %JAVA_HOME%bin
. So when you want to change the JDK you change only the JAVA_HOME
variable and leave PATH
as it is.
Georg Schölly
123k48 gold badges218 silver badges264 bronze badges
answered Sep 27, 2018 at 6:51
Lior Bar-OnLior Bar-On
10.4k5 gold badges32 silver badges45 bronze badges
17
Java 17 (LTS) and up
For Java 17 and up, you can use the Eclipse Adoptium website. According to their about section, the Eclipse Adoptium project is the continuation of the original AdoptOpenJDK mission.
Java 11 (LTS), Java 8 — 16
For Java 11 (8 through 16), you can use AdoptOpenJDK, a website hosted by the java community. You can find .msi installers for OpenJDK 8 through 16 there, which will perform all the things listed in the question (Unpacking, registry keys, PATH variable updating (and JAVA_HOME), uninstaller…).
answered May 27, 2019 at 13:47
PimgdPimgd
5,9531 gold badge30 silver badges44 bronze badges
2
Use the Chocolatey packet manager. It’s a command-line tool similar to npm. Once you have installed it, use
choco install openjdk --version=11.0
in an elevated command prompt to install OpenJDK 11 (leave out the --version
parameter to install the latest version).
To update an installed version to the latest version, type
choco upgrade openjdk
Pretty simple to use and especially helpful to upgrade to the latest version. No manual fiddling with path environment variables.
answered Jun 18, 2019 at 12:34
TobiasTobias
2,0202 gold badges25 silver badges49 bronze badges
10
From the comment by @ZhekaKozlov: ojdkbuild has OpenJDK builds (currently 8 and 11) for Windows (zip
and msi
).
4
You can use Amazon Corretto. It is free to use multiplatform, production-ready distribution of the OpenJDK. It comes with long-term support that will include performance enhancements and security fixes. Check the installation instructions here.
You can also check Zulu from Azul.
One more thing I like to highlight here is both Amazon Corretto and Zulu are TCK Compliant. You can see the OpenJDK builds comparison here and here.
answered Apr 27, 2020 at 17:39
SwapnilSwapnil
9441 gold badge12 silver badges20 bronze badges
https://www.openlogic.com/openjdk-downloads allowed me to pick a 32-bit version of OpenJDK8 (don’t ask — Arduino IDE doesn’t compile with 11), I think they just wrap around AdoptOpenJDK MSIs but I couldn’t find 32-bit distros on AdoptOpenJDK.
answered Mar 26, 2021 at 19:06
David AirapetyanDavid Airapetyan
5,0824 gold badges39 silver badges61 bronze badges
In addition to the above answers, it is worth noting that you have to move your JDK Path entry to the top of the Path
answered May 12, 2022 at 17:10
PrincePrince
20.1k6 gold badges39 silver badges58 bronze badges
Here is the complete answer. first of all you have to install the Chocolatey. to install Chocolatey run powershell as administrator and run the following command
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
after this run open cmd as administrator and run this command
choco install -y openjdk11
it will install the openjdk to the following location
C:Program FilesEclipse Adoptiumjdk-11.0.16.101-hotspot
finllay set your JAVA_HOME TO
C:Program FilesEclipse Adoptiumjdk-11.0.16.101-hotspot
and cheers
answered Sep 28, 2022 at 12:44
Engr.Aftab UfaqEngr.Aftab Ufaq
2,3202 gold badges14 silver badges40 bronze badges
WinGet is now available on Windows 10+ to install the Microsoft Build of OpenJDK on your machine. See details and access the downloads page at https://aka.ms/msopenjdk/ where Zip files and instructions.
answered Sep 29, 2022 at 6:17
d3r3kkd3r3kk
3,2352 gold badges17 silver badges22 bronze badges
Scoop installs programs you know and love, from the command line with a minimal amount of friction.
- Install scoop
- Add java
scoop bucket add java
- Install OpenJDK
scoop.cmd install openjdk17
answered Jan 2 at 14:06
jfkjfk
3,69330 silver badges25 bronze badges
OpenJDK 11
Abstract
OpenJDK 11 for Windows is a Red Hat offering on the Microsoft Windows platform. The Installing and using OpenJDK 11 for Windows guide provides an overview of this product and explains how to install the software and start using it.
Making open source more inclusive
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.
Providing feedback on Red Hat documentation
We appreciate your feedback on our documentation. To provide feedback, you can highlight the text in a document and add comments.
This section explains how to submit feedback.
Prerequisites
- You are logged in to the Red Hat Customer Portal.
- In the Red Hat Customer Portal, view the document in Multi-page HTML format.
Procedure
To provide your feedback, perform the following steps:
-
Click the Feedback button in the top-right corner of the document to see existing feedback.
The feedback feature is enabled only in the Multi-page HTML format.
- Highlight the section of the document where you want to provide feedback.
-
Click the Add Feedback pop-up that appears near the highlighted text.
A text box appears in the feedback section on the right side of the page.
-
Enter your feedback in the text box and click Submit.
A documentation issue is created.
- To view the issue, click the issue tracker link in the feedback view.
Chapter 1. OpenJDK 11 for Windows installation options
OpenJDK 11 for Windows can be installed using an archive or through a graphical user interface using an MSI-based installer.
Depending on your circumstance, use one of the following installation methods:
- Installing OpenJDK with the archive
- Installing OpenJDK with the MSI installer
Chapter 2. Installing OpenJDK 11 for Windows with the archive
This procedure describes how to manually install OpenJDK 11 for Windows using the archive.
Procedure
- Download the archive of OpenJDK 11 for Windows.
-
Extract the contents of an archive to a directory of your choice.
Extracting the contents of an archive to a directory path that does not contain spaces is recommended.
-
Update the
PATH
as below:-
Add the
bin
directory contained in your OpenJDK 11 for Windows installation path to the%PATH%
environment variable:C:> setx /m PATH "%PATH%;C:Progra~1RedHatjava-11-openjdk-11.0.1.13-1bin"
If the path contains spaces, use the shortened path name.
- Restart Command Prompt to reload the environment variables.
-
-
Verify the OpenJDK 11 for Windows is successfully installed, run
java -version
command in a command prompt and you must get the following output:openjdk version "11.0.3-redhat" 2019-04-16 LTS OpenJDK Runtime Environment 18.9 (build 11.0.3-redhat+7-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.3-redhat+7-LTS, mixed mode)
-
The
%JAVA_HOME%
environment variable must also be set to use some developer tools. Set the%JAVA_HOME%
environment variable as follows:- Open Command Prompt as an administrator.
-
Set the value of the environment variable to your OpenJDK 11 for Windows installation path:
C:> setx /m JAVA_HOME "C:Progra~1RedHatjava-11-openjdk-11.0.1.13-1"
If the path contains spaces, use the shortened path name.
- Restart Command Prompt to reload the environment variables.
Chapter 3. Updating OpenJDK 11 for Windows using the archive
OpenJDK 11 for Windows can be manually update using the archive.
Procedure
- Download the archive of OpenJDK 11.
-
Extract the contents of an archive to a directory of your choice.
Extracting the contents of an archive to a directory path that does not contain spaces is recommended.
-
On Command Prompt, update
JAVA_HOME
environment variable as follows:- Open Command Prompt as an administrator.
-
Set the value of the environment variable to your OpenJDK 11 for Windows installation path:
C:> setx /m JAVA_HOME "C:Progra~1RedHatjava-11-openjdk-11.0.1.13-1"
If the path contains spaces, use the shortened path name.
- Restart Command Prompt to reload the environment variables.
-
Set the value of
PATH
variable if it is not set already:C:> setx -m PATH "%PATH%;%JAVA_HOME%bin";
- Restart Command Prompt to reload the environment variables.
-
Verify that
java -version
works without supplying the full path.C:> java -version openjdk version "11.0.3" 2019-04-16 LTS OpenJDK Runtime Environment (build 11.0.3+7-LTS) OpenJDK 64-bit Server VM (build 11.0.3+7-LTS, mixed mode)
Chapter 4. Installing OpenJDK with the MSI installer
This procedure describes how to install OpenJDK 11 for Windows using the MSI-based installer.
Procedure
- Download the MSI-based installer of OpenJDK 11 for Windows.
- Run the installer for OpenJDK 11 for Windows.
-
Click
Next
on the welcome screen. -
Check
I accept the terms in license agreement
, then clickNext
. -
Click
Next
. - Accept the defaults or review the optional properties.
-
Click
Install
. -
Click
Yes
on theDo you want to allow this app to make changes on your device?
. -
Verify the OpenJDK 11 for Windows is successfully installed, run
java -version
command in the command prompt and you must get the following output:openjdk version "11.0.3-redhat" 2019-04-16 LTS OpenJDK Runtime Environment 18.9 (build 11.0.3-redhat+7-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.3-redhat+7-LTS, mixed mode)
Chapter 5. OpenJDK MSI installer components
(Optional) Set the following OpenJDK 11 for Windows MSI-based installer components:
- jdk
- Java Development Kit (JDK) files.
- jdk-registry-standard
-
Registry keys:
HKLMSoftwareJavaSoftJDK<version>, entries: JavaHome: <INSTALLDIR> RuntimeLib: <INSTALLDIR>binserverjvm.dll HKLMSoftwareJavaSoftJDK, entries: CurrentVersion: <version>
- jdk_env_path
-
Appends
<INSTALLDIR>bin
to the system%PATH%
environment variable. - jdk_env_java_home
-
Sets
<INSTALLDIR>
to the system%JAVA_HOME%
environment variable. - jdk_env_vendor_java_home
-
Sets
<INSTALLDIR>
to the system%REDHAT_JAVA_HOME%
environment variable. - jdk_registry_jar
- Association for JAR files. Launch JAR files with the OpenJDK context menu.
- jmc
-
JDK Mission Control files, installed into
<INSTALLDIR>missioncontrol
. - jmc_env
-
Appends
<INSTALLDIR>missioncontrol
to the system%PATH%
environment variable.
Appendix A. MSI-based installer properties
The OpenJDK 11 for Windows MSI-based installer includes the JDK Files component and the following optional properties:
Table A.1. OpenJDK 11 for Windows MSI-based installer properties
Property | Description | Default value |
---|---|---|
OpenJDK Runtime — Windows Registry |
The following registry keys are set HKLMSoftwareJavaSoftJDK<version>, entries: JavaHome: <INSTALLDIR> RuntimeLib: <INSTALLDIR>binserverjvm.dll HKLMSoftwareJavaSoftJDK, entries: CurrentVersion: <version> |
Yes |
OpenJDK Runtime — Path Variable |
Adds the Runtime to the Path variable so it is available from the command line. |
Yes |
OpenJDK Runtime — JAVA_HOME System Variable |
JAVA_HOME is used by some programs to find the Java runtime. |
No |
OpenJDK Runtime — REDHAT_JAVA_HOME System Variable |
REDHAT_JAVA_HOME can be used by some programs to find the Red Hat OpenJDK runtime. |
No |
OpenJDK Runtime — Jar Files Association |
This enables Jar files to be run from within Windows Explorer. |
No |
Mission Control — Files |
Contains files that are installed in the <installdir>missioncontrol directory. |
No |
Mission Control — Path Variable |
Appends <installdir>missioncontrol to the system PATH environment variable. |
No |
Revised on 2021-10-25 12:30:57 UTC
Legal Notice
Copyright © 2021 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license («CC-BY-SA»). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation’s permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
This tutorial provides all the steps required to install OpenJDK 18 on Windows 10. The steps to install OpenJDK 18 on other versions of Windows should be similar to the steps explained in this tutorial.
You may also install the popular IDEs to develop Java applications by following — How To Install Eclipse For Java On Windows, How To Install IntelliJ IDEA for Java on Windows, and How To Install VSCode For Java On Windows. You may also follow the How To Install OpenJDK 18 On Ubuntu to install the latest OpenJDK on Ubuntu and How To Install Java 18 On Ubuntu to install Oracle JDK.
Step 1 — Download OpenJDK
Open the JDK 18 GA Release site and download the distribution for Windows as highlighted in Fig 1.
Fig 1
Click the zip download link as highlighted in Fig 1 to download OpenJDK for Windows. Also, verify your download using the given sha256 checksum.
Step 2 — Install OpenJDK
Extract the downloaded zip to the desired location. In my case, I have extracted the downloaded zip to C:javaopenjdk. The final path should be C:javaopenjdkjdk-18.0.1.1.
This is the only step required to install OpenJDK on windows.
Step 3 — Set Environment Variables
In this step, we will configure the environment variables to use the OpenJDK from Command Prompt. Open Command Prompt and check the installed version of Java using the command java -version as shown in Fig 2.
Fig 2
It shows the version of Java 18 since my current version of Java is 18. In your case it might show another version of Java if it’s already installed, else it will show the message — Java is not recognized as internal or external command, operable program or batch file.
Right Click -> My Computer(This PC) -> Properties -> Advanced System Settings
The above steps will open the Windows Settings Panel as shown in Fig 3.
FIg 3
Now click the Environment Variables Button, select Path under the System Variables section, and click the Edit Button. We need to add the path of installed JDK to the system Path.
Click on the New/Edit Button and add/update the path to the installed JDK bin which is C:javaopenjdkopenjdk-18.0.1.1bin in our case. You might be required to update the path if it already exists. It should look like Fig 4.
Fig 4
Press the OK Button 3 times to close all the windows. This sets the JDK 18 on system environment variables to access the same from the console.
Notes: Remove existing PATH values specific to previously installed Java. Also update JAVA_HOME, in case it was already set. Also, you might be required to remove the previously installed JDK from the Global Path as shown in Fig 5.
Fig 5
Now again open the console and test the Java version as shown in Fig 6. Make sure to use a new console to test the version of the newly installed OpenJDK 18.
Fig 6
It must show the OpenJDK version as shown in Fig 6. You might need to restart the system in case it does not reflect the JDK version installed by us.
Getting started with Java — Hello World
In this step, we will write, compile, and execute our first program in Java using the standard Hello World example.
Now write the first Java program as shown below, save the program as HelloWorld.java and exit the editor. Make sure that the class name and file name are the same.
class HelloWorld {public static void main( String[] args ) {
System.out.println( "Hello World !!n" );
}
}
Now open the command prompt and navigate to the path where you have saved your Java program. Use the below-mentioned commands to compile and execute the program.
# Compile - Specify file name and extension
javac HelloWorld.java# Execute - Spicy file name
java HelloWorld# Output
Hello World !!
These are the easy-to-install steps required to install OpenJDK on Windows and write and execute the Java program.
Summary
This tutorial provided the steps required to download and install the most recent versions of OpenJDK i.e. JDK 18 and also provided the steps to write, compile, and execute the first Java program.
Инструкция по установке OpenJDK11
Важно: если у вас что-то не получилось, то оформляйте Issue по установленным правилам.
Windows
Шаг 1. Перейдите на сайт adoptopenjdk.
Шаг 2. Выберите среди списка подходящую для вашей операционной системы версию как на скриншоте ниже и нажмите на кнопку скачивания (главное выбрать 11ю версию джавы, другие цифры могут не совпадать):
Выбор между 32битной и 64битной версией. Узнать какая битность у вашей ОС можно по инструкции тут.
Шаг 3. Запустите на установку скачанный MSI-файл и нажмите кнопку «Next»:
Шаг 4. Прочитайте и согласитесь с условиями лицензии:
Шаг 5. Выберите опции как на экране (удостоверьтесь, что установка происходит в Program Files
и опция Add to PATH
выбрана):
Шаг 6. Нажмите на кнопку «Install»:
Шаг 7. Дождитесь окончания установки и нажмите на кнопку «Finish»:
Откройте терминал и выполните команду:
Вы должны увидеть вывод подобный:
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)
Важно: вы должны открывать терминал уже после того, как произвели установку.
MacOS
Шаг 1. Перейдите на сайт adoptopenjdk.net.
Шаг 2. Выберите опции как на скриншоте ниже и нажмите на кнопку скачивания в соответствии с версии вашего мака:
Шаг 3. Запустите на установку скачанный PKG-файл и нажмите кнопку «Продолжить»:
Шаг 4. Прочитайте и согласитесь с условиями лицензии:
Шаг 5. Выберите диск для установки:
Шаг 6. Нажмите на кнопку «Установить»:
Шаг 7. Дождитесь окончания установки и нажмите на кнопку «Закрыть»:
Откройте терминал и выполните команду:
Вы должны увидеть вывод подобный:
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)
Важно: вы должны открывать терминал уже после того, как произвели установку.
Linux
Указанные инструкции приведены для дистрибутива Ubuntu 18.04+. Если у вас другой дистрибутив Linux — пишите в канал Slack.
Откройте консоль (Ctrl + Alt + T
в Ubuntu 18+). В консоли выполните следующие команды:
sudo apt update sudo apt install openjdk-11-jdk openjdk-11-source
Удостоверьтесь, что java установлена:
Вы должны увидеть вывод подобный:
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.1)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.1, mixed mode, sharing)
Open Java Development Kit (OpenJDK) is an open source implementation of the Java Standard Edition (Java SE) platform with contribution from Oracle and the open Java community. For more information, see OpenJDK.
Open JavaFX (OpenJFX) is an open source, next generation client application platform for desktop, mobile and embedded systems built on Java. For more information, see JavaFX.
Before JDK version 9, JavaFX libraries were included in the JDK distribution. Since JDK version 9, JavaFX (JFX) is provided as a separate package.
This document explains how to install the OpenJDK version 12 along with OpenJFX libraries for the following operating systems:
- Windows
- Linux
- MacOS
Install OpenJDK
To install OpenJDK, you must download it as follow:
- Download the OpenJDK version 12 from https://jdk.java.net/archive/.
- Extract the .tar file. The
jdk-12.0.2
folder appears.
Install OpenJDK for Windows
This section explains how to install the OpenJDK version 12 for Windows:
-
Go to Start > Control Panel > System and Security > System.
-
Click Advanced system settings. The System Properties window appears.
-
Click Environment Variables…. The Environment Variables window appears.
-
Click New… in the User variables for <user name> section.
Note If your
JAVA_HOME
variable is already created, select it and click Edit…. -
Enter
JAVA_HOME
in the variable name field and the JDK directory path, for example,C:UsersuserDesktopjdk-12.0.2
, in the Variable value field. -
Click OK. The Environment Variables window appears.
-
If you cannot find
JAVA_HOME
in System variables section, add the variable by repeating the 4, 5, and 6 steps. -
Save and close the Environment Variables window.
-
Launch Command Prompt.
-
Run the following command to verify whether the OpenJDK version 12 is installed:
java -version
Install OpenJDK for Ubuntu
This section explains how to install the OpenJDK version 12 for Ubuntu:
-
Launch the Terminal application.
-
Run the following command in the terminal to set the
JAVA_HOME
as OpenJDK directory path, for example:JAVA_HOME=/home/<username>/Desktop/openJDK/jdk-12.0.2/
-
Run the following commands in the terminal:
sudo update-alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 20000 sudo update-alternatives --install /usr/bin/javac javac ${JAVA_HOME}/bin/javac 20000
-
Run the following command to get a list of JDK versions installed:
sudo update-alternatives --config java
Note If there are multiple JDK installed, select the required java version by entering the selection number.
-
Run the following command:
sudo update-alternatives --config javac
Note
javac
is for compilation. For more information on differences between java and javac, see https://docs.oracle.com. -
Select the required javac version as mentioned above.
-
Run the following command to verify whether the OpenJDK version 12 is installed:
java -version
Install OpenJDK for MacOS
This section explains how to install the OpenJDK version 12 for macOS:
-
Copy the downloaded jdk folder to the
Library/Java/JavaVirtualMachines
location. This is the default location where all the JDKs are available. Use the following command to copy the JDK directory.cp -aR <downloaded_jdk_path> /Library/Java/JavaVirtualMachines/
-
Launch Terminal application.
-
Run the following command to verify whether the OpenJDK version 12 is installed:
java -version
Note If the OpenJDK version 12 is not installed, add the
export JAVA_HOME = /Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home
command in the.profile
or.bash_profile
file.
Install OpenJFX
After installing OpenJDK, install the OpenJFX:
-
Download the OpenJFX version 11 from https://gluonhq.com/products/javafx.
Note Download the appropriate JavaFX product for your operating system.
-
Extract the downloaded zip file.
-
Copy all files in
lib
folder tolib
folder ofJAVA_HOME
.Note
On Ubuntu, run the following command:
cd javafx-sdk-11.0.1 sudo cp -arf lib/* ${JAVA_HOME}/lib/
-
Copy all files in
bin
folder tobin
folder ofJAVA_HOME
.Note This step is only required for Windows.