
Building 32-bit OpenJDK 6 on Windows 7 SP1
Windows builds are much more cumbersome than Linux ones. Despite that, GCC toolchain is available on Windows. Through the MinGW project, OpenJDK uses official Microsoft compilers from Visual Studio and Windows SDK. This brings a lot of complications because the Microsoft toolchain doesn't work well with the Unix-like environment provided by Cygwin.
Visual Studio.NET 2003 is required to build i586 binaries. OpenJDK 6 on Windows i586 is the only version in this book that cannot be built using freely available tools. VS 2003 was chosen for OpenJDK 6 because it supports Windows 2000, which was critical at the time of Sun Java 6's development.
Getting ready
For this recipe, we should have Windows 7 SP1 i586 running with no antivirus software installed. Antivirus software is not allowed because it may interfere with the Cygwin runtime.
How to do it...
The following steps will help us to build OpenJDK 6:
- Install Visual Studio.NET 2003 to the default installation path. Only the prerequisites and the Visual C++.NET component are required.
- Install or copy the preinstalled version of Cygwin to
c:\cygwin
. - Download and install Microsoft DirectX 9.0 SDK (Summer 2004) to the default installation path. Note that this distribution is not available anymore from the http://www.microsoft.com/en-in/default.aspx website. We can download it from some other places online and check the file details:
name: dxsdk_sum2004.exe size: 239008008 bytes sha1sum: 73d875b97591f48707c38ec0dbc63982ff45c661
- Download Platform Software Development Kit Redistributable: Microsoft Layer for Unicode on Windows 95, 98, and Me Systems, 1.1.3790.0 from http://www.microsoft.com/en-in/default.aspx and install it into the
c:\unicows
directory. - Download
unicows.lib
from theopenjdk-unofficial-builds
GitHub project and put this into thec:\unicows
directory too. - Download the Apache Ant version 1.8.4 ZIP distribution from the http://apache.org/ website and decompress it into the
c:\ant
directory. - Download GNU make utility binary from the http://www.cmake.org/ website using http://www.cmake.org/files/cygwin/make.exe-cygwin1.7, rename it to
make.exe
, and put it into thec:\make
directory. - Create the
c:\path_prepend
directory and copy thefind.exe
andsort.exe
files from the Cygwin installation. - Download the prebuilt FreeType libraries from the
openjdk-unofficial-builds
GitHub project (directory6_32
) and put the binaries into thec:\freetype
directory and header files into thec:\freetype\include
directory. - Install OpenJDK 6 binaries or Oracle Java 6 into
c:\jdk6
. - Download the official OpenJDK 6 build 30 sources tarball from the https://java.net/projects/openjdk6/downloads web page and decompress it into the
c:\sources
directory (warning: the tarball does not include theroot
directory) - In the
sa.make
file athotspot\make\windows\makefiles
, change line 100 fromSA_CFLAGS = $(SA_CFLAGS) /ZI
to:SA_CFLAGS = $(SA_CFLAGS) /Zi
- Create a
build.bat
batch file and write the following environment variables settings there:@echo off set LD_LIBRARY_PATH= set CLASSPATH= set JAVA_HOME= set PATH=c:/path_prepend;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;c:/make;c:/cygwin/bin;c:/jdk6/bin;c:/ant/bin set ALT_BOOTDIR=c:/jdk6 set ALT_FREETYPE_LIB_PATH=c:/freetype set ALT_FREETYPE_HEADERS_PATH=c:/freetype/include set ALT_UNICOWS_LIB_PATH=c:/unicows set ALT_UNICOWS_DLL_PATH=c:/unicows call "C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/Tools/vsvars32.bat" bash echo Press any key to close window ... pause > nul
- Run
build.bat
from Windows Explorer. Thecmd.exe
window should appear with bash launched. - From the bash Command Prompt run the following commands:
cd /cygdrive/c/sources chmod –R 777 make > make.log 2>&1
- Launch another Cygwin console and run the following commands:
cd /cygdrive/c/sources tail -f make.log
- Wait for the build to finish.
How it works...
Cygwin installation is covered in the Installing Cygwin for Windows builds recipe of this chapter.
Directories in the root of disk C
are used here for brevity. Generally, arbitrary paths consisting of ASCII letters or numbers and without spaces can be used.
Visual Studio 2003 is not officially supported on Windows 7. It warns about possible compatibility problems and may have glitches in the GUI interface, but its command-line tools work fine and the GUI interface is not needed for the OpenJDK build.
The newer version of DirectX SDK may also be used.
Different GNU make versions may have different problems on Windows. This particular version from the cmake
project was tested on different Windows versions and works fine.
This recipe uses prebuilt FreeType 2.4.10 libraries from the openjdk-unofficial-builds
GitHub project. FreeType may be built from sources using Visual Studio 2003. Please see the Building 32-bit FreeType libraries for OpenJDK 6 on Windows recipe in this chapter.
A patch for HotSpot serviceability Makefile
file is required to circumvent the VS2003 bug discovered after one of the recent security updates. This change is going to be upstreamed into official OpenJDK 6 sources and may not be required for more recent source tarballs.
In environment settings, additional attention should be paid to the order of the contents of the PATH
variable order. The sort
and find
Cygwin utilities go at the start of the PATH
variable so they are not overshadowed by Windows utilities with the same name but a different functionality. The make
utility is going goes before Cygwin to not be so they are not overshadowed by another version of make that may be included in the Cygwin installation.
The chmod 777
command is required to fix Cygwin file permissions that may cause errors in later stages of the build.
The make
output will be redirected to the make.log
file. The 2>&1
statement ensures that both stdout
and stderr
will be redirected.
The tail -f
command allows us to watch the contents of the make.log
file as they are written during the build process.
The pause > nul
command is added at the end of the batch file to prevent the cmd.exe
window from disappearing in the case of runtime errors.
There's more...
To build the most compatible binaries, the same recipe should be used, but the Windows 2000 operating system should be used instead of Windows 7.
In Windows 2000, the chmod 777
command is not required.
See also
- The Installing Cygwin for Windows builds recipe
- The Building OpenJDK 6 on Ubuntu Linux 12.04 LTS recipe, for information about build tuning
- The Building 32-bit FreeType libraries for OpenJDK 6 on Windows recipe
- The Preparing CA certificates recipe
- The official build instructions for OpenJDK 6 at http://hg.openjdk.java.net/jdk6/jdk6/raw-file/tip/README-builds.html
- The mailing list thread about the Serviceability HotSpot patch at http://mail.openjdk.java.net/pipermail/jdk6-dev/2013-December/003163.html