Sunday, 20 January 2013

Building Java 8 on Windows

This post is a step by step to build Java 8 using the new build infrastructure on Window (8 64bits). It combines instructions from Volker Simonis, Stanislav Kobylansky and from the OpenJDK8 Build ReadMe.
A different version of these steps initiated by Patrick Reinhart can be found on the Adopt OpenJDK website.
One more version with screenshots by Roberto Coelho.

Last updated: 2013-10-11: added the direct link to VC++2010 web installer in English (for some reason it isn't available from the download page from France)
  1. Download Visual C++ 2010 Express (only C++ is needed, direct link), install it without optional products (ie without Silverlight or MS SQL 2008 Express SP1).
    (it is only needed to build Freetype)
  2. Download and install Windows SDK 7.1 (don't install the samples and .Net tools)
  3. Download and install Microsoft DirectX 9.0 SDK (the ReadMe says the version from summer 2004, however this does not seem to still be available from Microsoft, the version from June 2010 seems to be a working replacement)
  4. Download and install TortoiseHg (Mercurial client)
  5. Download and install Java 7 (if not already done)
  6. Download and install Cygwin in C:\cygwin64, select the following packages:
    • [Archive] unzip
    • [Archive] zip
    • [Base] gawk
    • [Devel] binutils
    • [Devel] make
    • [Interpreters] m4
    • [Utils] cpio
    • [Utils] files
    • [System] procps
  7. Create a C:\dev\ directory 
  8. Freetype
    1. Download the source
    2. Extract it to C:\dev\freetype-
    3. Either
      • Download prebuilt binaries from bintray and extract them so that the lib directory goes into C:\dev\freetype-
      • Build it yourself
        1. Go to C:\dev\freetype-\builds\win32\vc2010 and open freetype.sln
        2. Create a 64 bits configuration
          1. In the toolbar, click on the arrow by Win32, then on "Configuration Manager", then again click on Win32 below "Active solution platform", then on <New...>
          2. In the new dialog, call the new platform "x64" and copy its settings from Win32, click OK
          3. Back in the previous dialog select "Release Multithreaded" from "Active solution configuration" and Close
          4. Right click on the freetype project, then select Properties
          5. In the dialog adjust:
            • "Output Directory" from ".\..\..\..\objs\win32\vc2010\" to ".\..\..\..\lib\"
            •  "Intermediate Directory" from ".\..\..\..\objs\release_mt\" to ".\..\..\..\objs\release_mt_64\"
            •  "Target Name" from "freetype2411MT" to "freetype"
            •  "Platform Toolset" from "v100" to "Windows7.1SDK"
          6. Ok to save
          7. Right click on the freetype project then Build or press <F7> to build
          8. Once built, return to the properties dialog
            • "Configuration Type" from "Static library (.lib)" to "Dynamic Library (.dll)"
          9. Build again
  9. Copy msvcr100.dll to its own directory C:\dev\vcrt from either C:\Windows\System32 or C:\Program Files\Java\jdk1.7.0_XX\bin (this because the build process seem to have difficulties copying the file properly from C:\Windows\System32, and the JDK bin directory is in a path with spaces)
  10. Adjust the PATH by appending ";C:\cygwin64\bin"
  11. Open Cygwin terminal (from link on the desktop)
  12. cd /cygdrive/c/dev
  13. Get the root source:
    hg clone
  14. Move to the new directory
    cd /cygdrive/c/dev/jdk8
  15. Get the remainder of the source
  16. Force the permissions
    chmod -R u+rwxs /cygdrive/c/dev/jdk8
    (otherwise some files get access denied errors)
  17. Run the auto-conf script
    bash configure --with-freetype=/cygdrive/c/dev/freetype- --with-msvcr-dll=/cygdrive/c/dev/vcrt/msvcr100.dll
  18. Time for cooking
  19. Once done, open a new standard Windows console and navigate to
    check that java runs:
    bin\java -version
    or for something a bit more visual:
  20. If needed make the images (ie the directory layouts that are created when installing a jdk/jre from the Oracle installers - or something pretty close to them)
    make images
  21. enjoy!
For day to day refresh do the following (in the cygwin shell):
  1. Go to the JDK directory
    cd /cygdrive/c/dev/jdk8
  2. Get the sources updates
  3. Force the permissions
    chmod -R u+rwxs /cygdrive/c/dev/jdk8
  4. Re-heat
    make images
  5. If it fails, try
    make clean
    (it tends to fail in hotspot, in which case a
    make clean-hotspot
    is faster)
    then re-heat
  6. If it fails again, try to redo the configuration
    make dist-clean
    bash configure --with-freetype=/cygdrive/c/dev/freetype- --with-msvcr-dll=/cygdrive/c/dev/vcrt/msvcr100.dll
    then re-heat

No comments: