Windows OpenJDK Development Environment Setup
I documented how to set up an OpenJDK build environment for macOS and for Ubuntu Linux. Here is how to do the same for a Windows x86-64 environment on a Windows x86-64 machine. To create a JDK build for a Windows ARM64 environment, see the last section of this post.
- Install Visual Studio Code.
- Install Git and set Visual Studio Code as Git’s default editor.
- Install Visual Studio 2019. Ensure the Desktop Development with C++ workload is selected so that the C++ compiler is available.
- Install a boot JDK. I used winget, the Windows package manager, to do this as outlined in the OpenJDK Windows installation instructions.
winget search Microsoft.OpenJDK
winget install Microsoft.OpenJDK.17
- Install Cygwin using the command below.
setup-x86_64.exe -q -P autoconf -P make -P unzip -P zip
- Launch Cygwin, clone the OpenJDK repo then run
bash configure
. This should output an error if there are any missing dependencies. Once that completes successfully,make images
will build the OpenJDK code.
mkdir ~/repos
cd ~/repos
git clone https://github.com/openjdk/jdk
cd ~/repos/jdk
bash configure
make images
To try out the local JDK build, run java.exe in the build folder, e.g.
cd ~/repos/jdk/build/windows-x86_64-server-slowdebug
cd jdk/bin
./java.exe -version
Troubleshooting
Keep in mind that make images
can fail due to Cygwin-specific issues. The only workaround may be to downgrade Cygwin to a version known to work well, as I had to do when I ran into segfaults when running make.
Windows ARM64 JDK
To create a JDK build for a Windows ARM64 machine (as of this posting), you still need to set up the Windows x86-64 environment as described above with the additional changes below.
- Launch the Visual Studio Installer then install the “MSVC v142 – VS 2019 C++ ARM64 build tools (Latest)” item.
- Run
bash configure
with the additional –openjdk-target argument as outlined at https://github.com/microsoft/openjdk-aarch64
bash configure --openjdk-target=aarch64-unknown-cygwin
Running the ARM64 JDK on x86-64?
I was curious to see what happens if you try to run the ARM64 Java build in Cygwin on x86-64:
User@Machine /cygdrive/c/dev/repos/jdk/build/windows-aarch64-server-release/jdk/bin
$ ./java -version
-bash: ./java: cannot execute binary file: Exec format error
In the Windows command line we get this message in the terminal and the subsequent dialog box:
C:\dev\repos\jdk\build\windows-aarch64-server-release\jdk\bin>.\java.exe
This version of C:\dev\repos\jdk\build\windows-aarch64-server-release\jdk\bin\java.exe is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
Launching it from Windows Explorer fails with this error:
Leave a Reply