Sunday 13 January 2019

Buildling OpenJDK with Windows Subsystem for Linux

Thanks to Andrew Luo (and the JDK build team), it is now possible to build OpenJDK with Windows Subsystem for Linux on Windows 10 (1809+). This post will also use the JDK mirror at Github (if it is not synchronised, see the previous post for using Mercurial).

2019-01-19: added the Mercurial instructions
  1. Activate Windows Subsystem for Linux
    In an administrative Powershell:
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    Restart then install, say, Ubuntu from the Windows Store
    Then launch wsl and complete the inialisation.
    See Microsoft documentation for the full instructions
  2. Create a C:\dev\ directory 
  3. Download and install Git (or/and Mercurial)
  4. Download OpenJDK 11 and extract it to C:\dev\jdk-11.0.1
  5. Download and install Visual Studio 2017 Build Tools (when installing select the Visual C++ Build Tools, and ensure the language module is English (only))
  6. In a WSL console select the following packages
    sudo apt install autoconf
    sudo apt install make
    sudo apt install zip
     (unzip will be installed with zip)
  7. Get OpenJDK's source:
    in a (cmd) console:
    cd C:\dev
    git clone https://github.com/openjdk/jdk.git
    or if it is not up to date:

    hg clone http://hg.openjdk.java.net/jdk/jdk/
    alternatively instead of attempting to clone from hg.openjdk.java.net (especially from Europe), download and extract Alexsey Shipilev's https://builds.shipilev.net/workspaces/jdk-jdk.tar.xz then extract in C:\dev\jdk then
    cd C:\dev
    hg pull
    hg update

  8. Build OpenJDK
    in a (wsl) console:
    cd /mnt/c/dev/jdk
    bash configure --with-boot-jdk=/mnt/c/dev/jdk-11.0.1/ --disable-warnings-as-errors
    make images
    (--disable-warnings-as-errors so that VS2017 warnings are not stopping the build)
  9. Test it
    in a (cmd) console:

    C:\dev\jdk\build\windows-x86_64-server-release\images\jdk\bin\java --version
  10. hack!
See the JDK's building.md document for more information.

No comments: