Как установить openjdk на windows 10

OpenJDK (Open Java Development Kit) is a free and open-source implementation of the Java Platform, Standard Edition (Java SE).

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 JAVA_HOME environment variable may not extract the path correctly if their is a space present.

Procedure

  1. Download the zip bundle of OpenJDK 11 for Windows.

  2. 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.

  3. 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.

  4. 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)
  5. The %JAVA_HOME% environment variable must also be set to use some developer tools.

    Set the %JAVA_HOME% environment variable as

    C:> setx /m JAVA_HOME "<YOUR_INSTALL_PATH>"

    Note

    JAVA_HOME will not work if the bin directory is appended to your installation path.

    After restarting the command prompt, you can view your setting by typing echo %JAVA_HOME%.

  6. Open Command Prompt as an administrator.

  7. 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.

  8. 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

  1. Download the MSI-based installer for OpenJDK 11 for Windows.

  2. Run the installer for OpenJDK 11 for Windows.

  3. Click Next on the Welcome Screen

  4. Check I accept the terms in the License Agreement, then click Next

  5. Click Next and accept the defaults, review the optional properties below if you wish to make changes.

  6. Click Install

  7. Click Yes on, «Do you want to allow this app to make changes to your device?».

  8. 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<version>, entries:
JavaHome: <INSTALLDIR>
RuntimeLib: <INSTALLDIR>binserverjvm.dll

HKLMSoftwareJavaSoftJDK, entries:
CurrentVersion: <version>

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

  1. Download the ZIP bundle of 11.0.3.

  2. 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.

  3. On the command prompt, update JAVA_HOME environment variable as follows:

  4. Open Command Prompt as an administrator.

  5. 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.

  6. Restart Command Prompt to reload the environment variables.

  7. Set the value of path variable if it is not set already:

    C:> setx -m PATH "%PATH%;%JAVA_HOME%bin";
  8. Restart the command prompt to reload the environment variables.

  9. 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

  1. Log in as a Windows system administrator.

  2. On the command line, set the prompt to C:/.

  3. Enter dir /b /s java.exe to list all of the installed JDKs on the system.

  4. 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.

  5. Restart the command prompt to reload the environment variables.

  6. Retrieve the value of the path variable:

  7. 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

  1. Unarchive the zip

  2. In the missioncontrol directory, open the JMC client executable file.

    OpenJDK entities

  3. On the command line, start the JMC Client by entering jmc or the the full path to the JMC executable.

    JAVA_HOMEmissioncontroljmc.exe
  4. On the JMC Client screen, create a new connection from the File Menu, choose your JVM, and start JMX console.

  5. 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

  1. 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

Gili's user avatar

GiliGili

84.3k94 gold badges382 silver badges680 bronze badges

17

  1. Extract the zip file into a folder, e.g. C:Program FilesJava and it will create a jdk-11 folder (where the bin folder is a direct sub-folder). You may need Administrator privileges to extract the zip file to this location.

  2. 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"
  3. 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.
  4. 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's user avatar

Georg Schölly

123k48 gold badges218 silver badges264 bronze badges

answered Sep 27, 2018 at 6:51

Lior Bar-On's user avatar

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

Pimgd's user avatar

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

Tobias's user avatar

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

Swapnil's user avatar

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 Airapetyan's user avatar

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

Inside System Variables Edit Path and Move Up the latest JDK entry to the top

answered May 12, 2022 at 17:10

Prince's user avatar

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 Ufaq's user avatar

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

d3r3kk's user avatar

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

jfk's user avatar

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:

  1. 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.

  2. Highlight the section of the document where you want to provide feedback.
  3. 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.

  4. Enter your feedback in the text box and click Submit.

    A documentation issue is created.

  5. 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

  1. Download the archive of OpenJDK 11 for Windows.
  2. 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.

  3. Update the PATH as below:

    1. 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.

    2. Restart Command Prompt to reload the environment variables.
  4. 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)
  5. The %JAVA_HOME% environment variable must also be set to use some developer tools. Set the %JAVA_HOME% environment variable as follows:

    1. Open Command Prompt as an administrator.
    2. 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.

    3. 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

  1. Download the archive of OpenJDK 11.
  2. 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.

  3. On Command Prompt, update JAVA_HOME environment variable as follows:

    1. Open Command Prompt as an administrator.
    2. 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.

    3. Restart Command Prompt to reload the environment variables.
  4. Set the value of PATH variable if it is not set already:

      C:> setx -m PATH "%PATH%;%JAVA_HOME%bin";
  5. Restart Command Prompt to reload the environment variables.
  6. 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

  1. Download the MSI-based installer of OpenJDK 11 for Windows.
  2. Run the installer for OpenJDK 11 for Windows.
  3. Click Next on the welcome screen.
  4. Check I accept the terms in license agreement, then click Next.
  5. Click Next.
  6. Accept the defaults or review the optional properties.
  7. Click Install.
  8. Click Yes on the Do you want to allow this app to make changes on your device?.
  9. 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.

Install OpenJDK 18 On Windows 10 - Download Options

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.

Install OpenJDK 18 On Windows 10 - Verify Installation

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.

Install OpenJDK 18 On Windows 10 - Path - Advanced Options

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.

Install OpenJDK 18 On Windows 10 - Configure Path

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.

Install OpenJDK 18 On Windows 10 - Remove Path

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.

Install OpenJDK 18 On Windows 10 - Verify Installation

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ю версию джавы, другие цифры могут не совпадать):

image

Выбор между 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. Выберите опции как на скриншоте ниже и нажмите на кнопку скачивания в соответствии с версии вашего мака:

image

Шаг 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:

  1. Download the OpenJDK version 12 from https://jdk.java.net/archive/.
  2. 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:

  1. Go to Start > Control Panel > System and Security > System.

  2. Click Advanced system settings. The System Properties window appears.

  3. Click Environment Variables…. The Environment Variables window appears.

  4. Click New… in the User variables for <user name> section.

    Note If your JAVA_HOME variable is already created, select it and click Edit….

  5. 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.

  6. Click OK. The Environment Variables window appears.

  7. If you cannot find JAVA_HOME in System variables section, add the variable by repeating the 4, 5, and 6 steps.

  8. Save and close the Environment Variables window.

  9. Launch Command Prompt.

  10. 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:

  1. Launch the Terminal application.

  2. 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/
    
  3. 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
    
  4. 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.

  5. 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.

  6. Select the required javac version as mentioned above.

  7. 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:

  1. 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/
    
  2. Launch Terminal application.

  3. 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:

  1. Download the OpenJFX version 11 from https://gluonhq.com/products/javafx.

    Note Download the appropriate JavaFX product for your operating system.

  2. Extract the downloaded zip file.

  3. Copy all files in lib folder to lib folder of JAVA_HOME.

    Note

    On Ubuntu, run the following command:

    cd javafx-sdk-11.0.1
    sudo cp -arf lib/* ${JAVA_HOME}/lib/
    
  4. Copy all files in bin folder to bin folder of JAVA_HOME.

    Note This step is only required for Windows.

Like this post? Please share to your friends:
  • Как установить node js на windows 10 через cmd
  • Как установить photoshop 2021 на windows 7
  • Как установить opengl на windows 10 intel
  • Как установить nmap на windows через командную строку
  • Как установить photoshop 2020 на windows 7