< prev index next >

doc/building.html

Print this page




 163 <p>At a minimum, a machine with 4 cores is advisable, as well as 4 GB of RAM. (The more cores to use, the more memory you need.) At least 8 GB of free disk space is required.</p>
 164 <h3 id="building-on-aarch64">Building on aarch64</h3>
 165 <p>At a minimum, a machine with 8 cores is advisable, as well as 8 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required.</p>
 166 <p>If you do not have access to sufficiently powerful hardware, it is also possible to use <a href="#cross-compiling">cross-compiling</a>.</p>
 167 <h3 id="building-on-32-bit-arm">Building on 32-bit arm</h3>
 168 <p>This is not recommended. Instead, see the section on <a href="#cross-compiling">Cross-compiling</a>.</p>
 169 <h2 id="operating-system-requirements">Operating System Requirements</h2>
 170 <p>The mainline JDK project supports Linux, Solaris, macOS, AIX and Windows. Support for other operating system, e.g. BSD, exists in separate &quot;port&quot; projects.</p>
 171 <p>In general, the JDK can be built on a wide range of versions of these operating systems, but the further you deviate from what is tested on a daily basis, the more likely you are to run into problems.</p>
 172 <p>This table lists the OS versions used by Oracle when building the JDK. Such information is always subject to change, but this table is up to date at the time of writing.</p>
 173 <table>
 174 <thead>
 175 <tr class="header">
 176 <th style="text-align: left;">Operating system</th>
 177 <th style="text-align: left;">Vendor/version used</th>
 178 </tr>
 179 </thead>
 180 <tbody>
 181 <tr class="odd">
 182 <td style="text-align: left;">Linux</td>
 183 <td style="text-align: left;">Oracle Enterprise Linux 6.4 / 7.6</td>
 184 </tr>
 185 <tr class="even">
 186 <td style="text-align: left;">Solaris</td>
 187 <td style="text-align: left;">Solaris 11.3 SRU 20</td>
 188 </tr>
 189 <tr class="odd">
 190 <td style="text-align: left;">macOS</td>
 191 <td style="text-align: left;">Mac OS X 10.13 (High Sierra)</td>
 192 </tr>
 193 <tr class="even">
 194 <td style="text-align: left;">Windows</td>
 195 <td style="text-align: left;">Windows Server 2012 R2</td>
 196 </tr>
 197 </tbody>
 198 </table>
 199 <p>The double version numbers for Linux and Solaris are due to the hybrid model used at Oracle, where header files and external libraries from an older version are used when building on a more modern version of the OS.</p>
 200 <p>The Build Group has a wiki page with <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a>. From time to time, this is updated by contributors to list successes or failures of building on different platforms.</p>
 201 <h3 id="windows">Windows</h3>
 202 <p>Windows XP is not a supported platform, but all newer Windows should be able to build the JDK.</p>
 203 <p>On Windows, it is important that you pay attention to the instructions in the <a href="#special-considerations">Special Considerations</a>.</p>
 204 <p>Windows is the only non-POSIX OS supported by the JDK, and as such, requires some extra care. A POSIX support layer is required to build on Windows. Currently, the only supported such layers are Cygwin and Windows Subsystem for Linux (WSL). (Msys is no longer supported due to a too old bash; msys2 would likely be possible to support in a future version but that would require effort to implement.)</p>
 205 <p>Internally in the build system, all paths are represented as Unix-style paths, e.g. <code>/cygdrive/c/hg/jdk9/Makefile</code> rather than <code>C:\hg\jdk9\Makefile</code>. This rule also applies to input to the build system, e.g. in arguments to <code>configure</code>. So, use <code>--with-msvcr-dll=/cygdrive/c/msvcr100.dll</code> rather than <code>--with-msvcr-dll=c:\msvcr100.dll</code>. For details on this conversion, see the section on <a href="#fixpath">Fixpath</a>.</p>
 206 <h4 id="cygwin">Cygwin</h4>
 207 <p>A functioning <a href="http://www.cygwin.com/">Cygwin</a> environment is required for building the JDK on Windows. If you have a 64-bit OS, we strongly recommend using the 64-bit version of Cygwin.</p>
 208 <p><strong>Note:</strong> Cygwin has a model of continuously updating all packages without any easy way to install or revert to a specific version of a package. This means that whenever you add or update a package in Cygwin, you might (inadvertently) update tools that are used by the JDK build process, and that can cause unexpected build problems.</p>
 209 <p>The JDK requires GNU Make 4.0 or greater in Cygwin. This is usually not a problem, since Cygwin currently only distributes GNU Make at a version above 4.0.</p>
 210 <p>Apart from the basic Cygwin installation, the following packages must also be installed:</p>
 211 <ul>
 212 <li><code>autoconf</code></li>
 213 <li><code>make</code></li>
 214 <li><code>zip</code></li>
 215 <li><code>unzip</code></li>
 216 </ul>
 217 <p>Often, you can install these packages using the following command line:</p>
 218 <pre><code>&lt;path to Cygwin setup&gt;/setup-x86_64 -q -P autoconf -P make -P unzip -P zip</code></pre>
 219 <p>Unfortunately, Cygwin can be unreliable in certain circumstances. If you experience build tool crashes or strange issues when building on Windows, please check the Cygwin FAQ on the <a href="https://cygwin.com/faq/faq.html#faq.using.bloda">&quot;BLODA&quot; list</a> and the section on <a href="https://cygwin.com/faq/faq.html#faq.using.fixing-fork-failures">fork() failures</a>.</p>


 264 <td style="text-align: left;">AIX</td>
 265 <td style="text-align: left;">IBM XL C/C++</td>
 266 </tr>
 267 <tr class="odd">
 268 <td style="text-align: left;">Windows</td>
 269 <td style="text-align: left;">Microsoft Visual Studio</td>
 270 </tr>
 271 </tbody>
 272 </table>
 273 <p>Please see the individual sections on the toolchains for version recommendations. As a reference, these versions of the toolchains are used, at the time of writing, by Oracle for the daily builds of the JDK. It should be possible to compile the JDK with both older and newer versions, but the closer you stay to this list, the more likely you are to compile successfully without issues.</p>
 274 <table>
 275 <thead>
 276 <tr class="header">
 277 <th style="text-align: left;">Operating system</th>
 278 <th style="text-align: left;">Toolchain version</th>
 279 </tr>
 280 </thead>
 281 <tbody>
 282 <tr class="odd">
 283 <td style="text-align: left;">Linux</td>
 284 <td style="text-align: left;">gcc 8.2.0</td>
 285 </tr>
 286 <tr class="even">
 287 <td style="text-align: left;">macOS</td>
 288 <td style="text-align: left;">Apple Xcode 10.1 (using clang 10.0.0)</td>
 289 </tr>
 290 <tr class="odd">
 291 <td style="text-align: left;">Solaris</td>
 292 <td style="text-align: left;">Oracle Solaris Studio 12.6 (with compiler version 5.15)</td>
 293 </tr>
 294 <tr class="even">
 295 <td style="text-align: left;">Windows</td>
 296 <td style="text-align: left;">Microsoft Visual Studio 2017 update 15.9.6</td>
 297 </tr>
 298 </tbody>
 299 </table>
 300 <p>All compilers are expected to be able to compile to the C99 language standard, as some C99 features are used in the source code. Microsoft Visual Studio doesn't fully support C99 so in practice shared code is limited to using C99 features that it does support.</p>
 301 <h3 id="gcc">gcc</h3>
 302 <p>The minimum accepted version of gcc is 4.8. Older versions will generate a warning by <code>configure</code> and are unlikely to work.</p>
 303 <p>The JDK is currently known to be able to compile with at least version 7.4 of gcc.</p>
 304 <p>In general, any version between these two should be usable.</p>
 305 <h3 id="clang">clang</h3>
 306 <p>The minimum accepted version of clang is 3.2. Older versions will not be accepted by <code>configure</code>.</p>
 307 <p>To use clang instead of gcc on Linux, use <code>--with-toolchain-type=clang</code>.</p>
 308 <h3 id="apple-xcode">Apple Xcode</h3>
 309 <p>The oldest supported version of Xcode is 8.</p>
 310 <p>You will need the Xcode command lines developers tools to be able to build the JDK. (Actually, <em>only</em> the command lines tools are needed, not the IDE.) The simplest way to install these is to run:</p>
 311 <pre><code>xcode-select --install</code></pre>
 312 <p>It is advisable to keep an older version of Xcode for building the JDK when updating Xcode. This <a href="http://iosdevelopertips.com/xcode/install-multiple-versions-of-xcode.html">blog page</a> has good suggestions on managing multiple Xcode versions. To use a specific version of Xcode, use <code>xcode-select -s</code> before running <code>configure</code>, or use <code>--with-toolchain-path</code> to point to the version of Xcode to use, e.g. <code>configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin</code></p>
 313 <p>If you have recently (inadvertently) updated your OS and/or Xcode version, and the JDK can no longer be built, please see the section on <a href="#problems-with-the-build-environment">Problems with the Build Environment</a>, and <a href="#getting-help">Getting Help</a> to find out if there are any recent, non-merged patches available for this update.</p>
 314 <h3 id="oracle-solaris-studio">Oracle Solaris Studio</h3>
 315 <p>The minimum accepted version of the Solaris Studio compilers is 5.13 (corresponding to Solaris Studio 12.4). Older versions will not be accepted by configure.</p>
 316 <p>The Solaris Studio installation should contain at least these packages:</p>
 317 <table>
 318 <thead>
 319 <tr class="header">
 320 <th style="text-align: left;">Package</th>


 353 <tr class="even">
 354 <td style="text-align: left;">developer/solarisstudio-124/studio-ja</td>
 355 <td style="text-align: left;">12.4-1.0.0.1</td>
 356 </tr>
 357 <tr class="odd">
 358 <td style="text-align: left;">developer/solarisstudio-124/studio-legal</td>
 359 <td style="text-align: left;">12.4-1.0.0.1</td>
 360 </tr>
 361 <tr class="even">
 362 <td style="text-align: left;">developer/solarisstudio-124/studio-zhCN</td>
 363 <td style="text-align: left;">12.4-1.0.0.1</td>
 364 </tr>
 365 </tbody>
 366 </table>
 367 <p>Compiling with Solaris Studio can sometimes be finicky. This is the exact version used by Oracle, which worked correctly at the time of writing:</p>
 368 <pre><code>$ cc -V
 369 cc: Sun C 5.13 SunOS_i386 2014/10/20
 370 $ CC -V
 371 CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30</code></pre>
 372 <h3 id="microsoft-visual-studio">Microsoft Visual Studio</h3>
 373 <p>The minimum accepted version of Visual Studio is 2010. Older versions will not be accepted by <code>configure</code>. The maximum accepted version of Visual Studio is 2019. Versions older than 2017 are unlikely to continue working for long.</p>
 374 <p>If you have multiple versions of Visual Studio installed, <code>configure</code> will by default pick the latest. You can request a specific version to be used by setting <code>--with-toolchain-version</code>, e.g. <code>--with-toolchain-version=2015</code>.</p>
 375 <p>If you get <code>LINK: fatal error LNK1123: failure during conversion to COFF: file invalid</code> when building using Visual Studio 2010, you have encountered <a href="http://support.microsoft.com/kb/2757355">KB2757355</a>, a bug triggered by a specific installation order. However, the solution suggested by the KB article does not always resolve the problem. See <a href="https://stackoverflow.com/questions/10888391">this stackoverflow discussion</a> for other suggestions.</p>
 376 <h3 id="ibm-xl-cc">IBM XL C/C++</h3>
 377 <p>Please consult the AIX section of the <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a> OpenJDK Build Wiki page for details about which versions of XLC are supported.</p>
 378 <h2 id="boot-jdk-requirements">Boot JDK Requirements</h2>
 379 <p>Paradoxically, building the JDK requires a pre-existing JDK. This is called the &quot;boot JDK&quot;. The boot JDK does not, however, have to be a JDK built directly from the source code available in the OpenJDK Community. If you are porting the JDK to a new platform, chances are that there already exists another JDK for that platform that is usable as boot JDK.</p>
 380 <p>The rule of thumb is that the boot JDK for building JDK major version <em>N</em> should be a JDK of major version <em>N-1</em>, so for building JDK 9 a JDK 8 would be suitable as boot JDK. However, the JDK should be able to &quot;build itself&quot;, so an up-to-date build of the current JDK source is an acceptable alternative. If you are following the <em>N-1</em> rule, make sure you've got the latest update version, since JDK 8 GA might not be able to build JDK 9 on all platforms.</p>
 381 <p>Early in the release cycle, version <em>N-1</em> may not yet have been released. In that case, the preferred boot JDK will be version <em>N-2</em> until version <em>N-1</em> is available.</p>
 382 <p>If the boot JDK is not automatically detected, or the wrong JDK is picked, use <code>--with-boot-jdk</code> to point to the JDK to use.</p>
 383 <h3 id="getting-jdk-binaries">Getting JDK binaries</h3>
 384 <p>JDK binaries for Linux, Windows and macOS can be downloaded from <a href="http://jdk.java.net">jdk.java.net</a>. An alternative is to download the <a href="http://www.oracle.com/technetwork/java/javase/downloads">Oracle JDK</a>. Another is the <a href="https://adoptopenjdk.net/">Adopt OpenJDK Project</a>, which publishes experimental prebuilt binaries for various platforms.</p>
 385 <p>On Linux you can also get a JDK from the Linux distribution. On apt-based distros (like Debian and Ubuntu), <code>sudo apt-get install openjdk-&lt;VERSION&gt;-jdk</code> is typically enough to install a JDK &lt;VERSION&gt;. On rpm-based distros (like Fedora and Red Hat), try <code>sudo yum install java-&lt;VERSION&gt;-openjdk-devel</code>.</p>
 386 <h2 id="external-library-requirements">External Library Requirements</h2>
 387 <p>Different platforms require different external libraries. In general, libraries are not optional - that is, they are either required or not used.</p>
 388 <p>If a required library is not detected by <code>configure</code>, you need to provide the path to it. There are two forms of the <code>configure</code> arguments to point to an external library: <code>--with-&lt;LIB&gt;=&lt;path&gt;</code> or <code>--with-&lt;LIB&gt;-include=&lt;path to include&gt; --with-&lt;LIB&gt;-lib=&lt;path to lib&gt;</code>. The first variant is more concise, but require the include files an library files to reside in a default hierarchy under this directory. In most cases, it works fine.</p>
 389 <p>As a fallback, the second version allows you to point to the include directory and the lib directory separately.</p>
 390 <h3 id="freetype">FreeType</h3>
 391 <p>FreeType2 from <a href="http://www.freetype.org/">The FreeType Project</a> is not required on any platform. The exception is on Unix-based platforms when configuring such that the build artifacts will reference a system installed library, rather than bundling the JDK’s own copy.</p>
 392 <ul>
 393 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libfreetype6-dev</code>.</li>


 481 <h4 id="configure-arguments-for-native-compilation">Configure Arguments for Native Compilation</h4>
 482 <ul>
 483 <li><code>--with-devkit=&lt;path&gt;</code> - Use this devkit for compilers, tools and resources</li>
 484 <li><code>--with-sysroot=&lt;path&gt;</code> - Use this directory as sysroot</li>
 485 <li><code>--with-extra-path=&lt;path&gt;[;&lt;path&gt;]</code> - Prepend these directories to the default path when searching for all kinds of binaries</li>
 486 <li><code>--with-toolchain-path=&lt;path&gt;[;&lt;path&gt;]</code> - Prepend these directories when searching for toolchain binaries (compilers etc)</li>
 487 <li><code>--with-extra-cflags=&lt;flags&gt;</code> - Append these flags when compiling JDK C files</li>
 488 <li><code>--with-extra-cxxflags=&lt;flags&gt;</code> - Append these flags when compiling JDK C++ files</li>
 489 <li><code>--with-extra-ldflags=&lt;flags&gt;</code> - Append these flags when linking JDK libraries</li>
 490 </ul>
 491 <h4 id="configure-arguments-for-external-dependencies">Configure Arguments for External Dependencies</h4>
 492 <ul>
 493 <li><code>--with-boot-jdk=&lt;path&gt;</code> - Set the path to the <a href="#boot-jdk-requirements">Boot JDK</a></li>
 494 <li><code>--with-freetype=&lt;path&gt;</code> - Set the path to <a href="#freetype">FreeType</a></li>
 495 <li><code>--with-cups=&lt;path&gt;</code> - Set the path to <a href="#cups">CUPS</a></li>
 496 <li><code>--with-x=&lt;path&gt;</code> - Set the path to <a href="#x11">X11</a></li>
 497 <li><code>--with-alsa=&lt;path&gt;</code> - Set the path to <a href="#alsa">ALSA</a></li>
 498 <li><code>--with-libffi=&lt;path&gt;</code> - Set the path to <a href="#libffi">libffi</a></li>
 499 <li><code>--with-jtreg=&lt;path&gt;</code> - Set the path to JTReg. See <a href="#running-tests">Running Tests</a></li>
 500 </ul>
 501 <p>Certain third-party libraries used by the JDK (libjpeg, giflib, libpng, lcms and zlib) are included in the JDK repository. The default behavior of the JDK build is to use the included (&quot;bundled&quot;) versions of libjpeg, giflib, libpng and lcms. For zlib, the system lib (if present) is used except on Windows and AIX. However the bundled libraries may be replaced by an external version. To do so, specify <code>system</code> as the <code>&lt;source&gt;</code> option in these arguments. (The default is <code>bundled</code>).</p>
 502 <ul>
 503 <li><code>--with-libjpeg=&lt;source&gt;</code> - Use the specified source for libjpeg</li>
 504 <li><code>--with-giflib=&lt;source&gt;</code> - Use the specified source for giflib</li>
 505 <li><code>--with-libpng=&lt;source&gt;</code> - Use the specified source for libpng</li>
 506 <li><code>--with-lcms=&lt;source&gt;</code> - Use the specified source for lcms</li>
 507 <li><code>--with-zlib=&lt;source&gt;</code> - Use the specified source for zlib</li>
 508 </ul>
 509 <p>On Linux, it is possible to select either static or dynamic linking of the C++ runtime. The default is static linking, with dynamic linking as fallback if the static library is not found.</p>
 510 <ul>
 511 <li><code>--with-stdc++lib=&lt;method&gt;</code> - Use the specified method (<code>static</code>, <code>dynamic</code> or <code>default</code>) for linking the C++ runtime.</li>
 512 </ul>
 513 <h3 id="configure-control-variables">Configure Control Variables</h3>
 514 <p>It is possible to control certain aspects of <code>configure</code> by overriding the value of <code>configure</code> variables, either on the command line or in the environment.</p>
 515 <p>Normally, this is <strong>not recommended</strong>. If used improperly, it can lead to a broken configuration. Unless you're well versed in the build system, this is hard to use properly. Therefore, <code>configure</code> will print a warning if this is detected.</p>
 516 <p>However, there are a few <code>configure</code> variables, known as <em>control variables</em> that are supposed to be overriden on the command line. These are variables that describe the location of tools needed by the build, like <code>MAKE</code> or <code>GREP</code>. If any such variable is specified, <code>configure</code> will use that value instead of trying to autodetect the tool. For instance, <code>bash configure MAKE=/opt/gnumake4.0/bin/make</code>.</p>
 517 <p>If a configure argument exists, use that instead, e.g. use <code>--with-jtreg</code> instead of setting <code>JTREGEXE</code>.</p>
 518 <p>Also note that, despite what autoconf claims, setting <code>CFLAGS</code> will not accomplish anything. Instead use <code>--with-extra-cflags</code> (and similar for <code>cxxflags</code> and <code>ldflags</code>).</p>
 519 <h2 id="running-make">Running Make</h2>
 520 <p>When you have a proper configuration, all you need to do to build the JDK is to run <code>make</code>. (But see the warning at <a href="#gnu-make">GNU Make</a> about running the correct version of make.)</p>
 521 <p>When running <code>make</code> without any arguments, the default target is used, which is the same as running <code>make default</code> or <code>make jdk</code>. This will build a minimal (or roughly minimal) set of compiled output (known as an &quot;exploded image&quot;) needed for a developer to actually execute the newly built JDK. The idea is that in an incremental development fashion, when doing a normal make, you should only spend time recompiling what's changed (making it purely incremental) and only do the work that's needed to actually run and test your code.</p>




 163 <p>At a minimum, a machine with 4 cores is advisable, as well as 4 GB of RAM. (The more cores to use, the more memory you need.) At least 8 GB of free disk space is required.</p>
 164 <h3 id="building-on-aarch64">Building on aarch64</h3>
 165 <p>At a minimum, a machine with 8 cores is advisable, as well as 8 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required.</p>
 166 <p>If you do not have access to sufficiently powerful hardware, it is also possible to use <a href="#cross-compiling">cross-compiling</a>.</p>
 167 <h3 id="building-on-32-bit-arm">Building on 32-bit arm</h3>
 168 <p>This is not recommended. Instead, see the section on <a href="#cross-compiling">Cross-compiling</a>.</p>
 169 <h2 id="operating-system-requirements">Operating System Requirements</h2>
 170 <p>The mainline JDK project supports Linux, Solaris, macOS, AIX and Windows. Support for other operating system, e.g. BSD, exists in separate &quot;port&quot; projects.</p>
 171 <p>In general, the JDK can be built on a wide range of versions of these operating systems, but the further you deviate from what is tested on a daily basis, the more likely you are to run into problems.</p>
 172 <p>This table lists the OS versions used by Oracle when building the JDK. Such information is always subject to change, but this table is up to date at the time of writing.</p>
 173 <table>
 174 <thead>
 175 <tr class="header">
 176 <th style="text-align: left;">Operating system</th>
 177 <th style="text-align: left;">Vendor/version used</th>
 178 </tr>
 179 </thead>
 180 <tbody>
 181 <tr class="odd">
 182 <td style="text-align: left;">Linux</td>
 183 <td style="text-align: left;">Oracle Enterprise Linux 6.4 / 7.1 (using kernel 3.8.13)</td>
 184 </tr>
 185 <tr class="even">
 186 <td style="text-align: left;">Solaris</td>
 187 <td style="text-align: left;">Solaris 11.1 SRU 21.4.1 / 11.2 SRU 5.5</td>
 188 </tr>
 189 <tr class="odd">
 190 <td style="text-align: left;">macOS</td>
 191 <td style="text-align: left;">Mac OS X 10.9 (Mavericks) / 10.10 (Yosemite)</td>
 192 </tr>
 193 <tr class="even">
 194 <td style="text-align: left;">Windows</td>
 195 <td style="text-align: left;">Windows Server 2012 R2</td>
 196 </tr>
 197 </tbody>
 198 </table>
 199 <p>The double version numbers for Linux, Solaris and macOS is due to the hybrid model used at Oracle, where header files and external libraries from an older version are used when building on a more modern version of the OS.</p>
 200 <p>The Build Group has a wiki page with <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a>. From time to time, this is updated by contributors to list successes or failures of building on different platforms.</p>
 201 <h3 id="windows">Windows</h3>
 202 <p>Windows XP is not a supported platform, but all newer Windows should be able to build the JDK.</p>
 203 <p>On Windows, it is important that you pay attention to the instructions in the <a href="#special-considerations">Special Considerations</a>.</p>
 204 <p>Windows is the only non-POSIX OS supported by the JDK, and as such, requires some extra care. A POSIX support layer is required to build on Windows. Currently, the only supported such layers are Cygwin and Windows Subsystem for Linux (WSL). (Msys is no longer supported due to a too old bash; msys2 would likely be possible to support in a future version but that would require effort to implement.)</p>
 205 <p>Internally in the build system, all paths are represented as Unix-style paths, e.g. <code>/cygdrive/c/hg/jdk9/Makefile</code> rather than <code>C:\hg\jdk9\Makefile</code>. This rule also applies to input to the build system, e.g. in arguments to <code>configure</code>. So, use <code>--with-msvcr-dll=/cygdrive/c/msvcr100.dll</code> rather than <code>--with-msvcr-dll=c:\msvcr100.dll</code>. For details on this conversion, see the section on <a href="#fixpath">Fixpath</a>.</p>
 206 <h4 id="cygwin">Cygwin</h4>
 207 <p>A functioning <a href="http://www.cygwin.com/">Cygwin</a> environment is required for building the JDK on Windows. If you have a 64-bit OS, we strongly recommend using the 64-bit version of Cygwin.</p>
 208 <p><strong>Note:</strong> Cygwin has a model of continuously updating all packages without any easy way to install or revert to a specific version of a package. This means that whenever you add or update a package in Cygwin, you might (inadvertently) update tools that are used by the JDK build process, and that can cause unexpected build problems.</p>
 209 <p>The JDK requires GNU Make 4.0 or greater in Cygwin. This is usually not a problem, since Cygwin currently only distributes GNU Make at a version above 4.0.</p>
 210 <p>Apart from the basic Cygwin installation, the following packages must also be installed:</p>
 211 <ul>
 212 <li><code>autoconf</code></li>
 213 <li><code>make</code></li>
 214 <li><code>zip</code></li>
 215 <li><code>unzip</code></li>
 216 </ul>
 217 <p>Often, you can install these packages using the following command line:</p>
 218 <pre><code>&lt;path to Cygwin setup&gt;/setup-x86_64 -q -P autoconf -P make -P unzip -P zip</code></pre>
 219 <p>Unfortunately, Cygwin can be unreliable in certain circumstances. If you experience build tool crashes or strange issues when building on Windows, please check the Cygwin FAQ on the <a href="https://cygwin.com/faq/faq.html#faq.using.bloda">&quot;BLODA&quot; list</a> and the section on <a href="https://cygwin.com/faq/faq.html#faq.using.fixing-fork-failures">fork() failures</a>.</p>


 264 <td style="text-align: left;">AIX</td>
 265 <td style="text-align: left;">IBM XL C/C++</td>
 266 </tr>
 267 <tr class="odd">
 268 <td style="text-align: left;">Windows</td>
 269 <td style="text-align: left;">Microsoft Visual Studio</td>
 270 </tr>
 271 </tbody>
 272 </table>
 273 <p>Please see the individual sections on the toolchains for version recommendations. As a reference, these versions of the toolchains are used, at the time of writing, by Oracle for the daily builds of the JDK. It should be possible to compile the JDK with both older and newer versions, but the closer you stay to this list, the more likely you are to compile successfully without issues.</p>
 274 <table>
 275 <thead>
 276 <tr class="header">
 277 <th style="text-align: left;">Operating system</th>
 278 <th style="text-align: left;">Toolchain version</th>
 279 </tr>
 280 </thead>
 281 <tbody>
 282 <tr class="odd">
 283 <td style="text-align: left;">Linux</td>
 284 <td style="text-align: left;">gcc 7.3.0</td>
 285 </tr>
 286 <tr class="even">
 287 <td style="text-align: left;">macOS</td>
 288 <td style="text-align: left;">Apple Xcode 9.4 (using clang 9.1.0)</td>
 289 </tr>
 290 <tr class="odd">
 291 <td style="text-align: left;">Solaris</td>
 292 <td style="text-align: left;">Oracle Solaris Studio 12.4 (with compiler version 5.13)</td>
 293 </tr>
 294 <tr class="even">
 295 <td style="text-align: left;">Windows</td>
 296 <td style="text-align: left;">Microsoft Visual Studio 2017 update 15.5.5</td>
 297 </tr>
 298 </tbody>
 299 </table>

 300 <h3 id="gcc">gcc</h3>
 301 <p>The minimum accepted version of gcc is 4.8. Older versions will generate a warning by <code>configure</code> and are unlikely to work.</p>
 302 <p>The JDK is currently known to be able to compile with at least version 7.4 of gcc.</p>
 303 <p>In general, any version between these two should be usable.</p>
 304 <h3 id="clang">clang</h3>
 305 <p>The minimum accepted version of clang is 3.2. Older versions will not be accepted by <code>configure</code>.</p>
 306 <p>To use clang instead of gcc on Linux, use <code>--with-toolchain-type=clang</code>.</p>
 307 <h3 id="apple-xcode">Apple Xcode</h3>
 308 <p>The oldest supported version of Xcode is 8.</p>
 309 <p>You will need the Xcode command lines developers tools to be able to build the JDK. (Actually, <em>only</em> the command lines tools are needed, not the IDE.) The simplest way to install these is to run:</p>
 310 <pre><code>xcode-select --install</code></pre>
 311 <p>It is advisable to keep an older version of Xcode for building the JDK when updating Xcode. This <a href="http://iosdevelopertips.com/xcode/install-multiple-versions-of-xcode.html">blog page</a> has good suggestions on managing multiple Xcode versions. To use a specific version of Xcode, use <code>xcode-select -s</code> before running <code>configure</code>, or use <code>--with-toolchain-path</code> to point to the version of Xcode to use, e.g. <code>configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin</code></p>
 312 <p>If you have recently (inadvertently) updated your OS and/or Xcode version, and the JDK can no longer be built, please see the section on <a href="#problems-with-the-build-environment">Problems with the Build Environment</a>, and <a href="#getting-help">Getting Help</a> to find out if there are any recent, non-merged patches available for this update.</p>
 313 <h3 id="oracle-solaris-studio">Oracle Solaris Studio</h3>
 314 <p>The minimum accepted version of the Solaris Studio compilers is 5.13 (corresponding to Solaris Studio 12.4). Older versions will not be accepted by configure.</p>
 315 <p>The Solaris Studio installation should contain at least these packages:</p>
 316 <table>
 317 <thead>
 318 <tr class="header">
 319 <th style="text-align: left;">Package</th>


 352 <tr class="even">
 353 <td style="text-align: left;">developer/solarisstudio-124/studio-ja</td>
 354 <td style="text-align: left;">12.4-1.0.0.1</td>
 355 </tr>
 356 <tr class="odd">
 357 <td style="text-align: left;">developer/solarisstudio-124/studio-legal</td>
 358 <td style="text-align: left;">12.4-1.0.0.1</td>
 359 </tr>
 360 <tr class="even">
 361 <td style="text-align: left;">developer/solarisstudio-124/studio-zhCN</td>
 362 <td style="text-align: left;">12.4-1.0.0.1</td>
 363 </tr>
 364 </tbody>
 365 </table>
 366 <p>Compiling with Solaris Studio can sometimes be finicky. This is the exact version used by Oracle, which worked correctly at the time of writing:</p>
 367 <pre><code>$ cc -V
 368 cc: Sun C 5.13 SunOS_i386 2014/10/20
 369 $ CC -V
 370 CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30</code></pre>
 371 <h3 id="microsoft-visual-studio">Microsoft Visual Studio</h3>
 372 <p>The minimum accepted version of Visual Studio is 2010. Older versions will not be accepted by <code>configure</code>. The maximum accepted version of Visual Studio is 2017. Versions older than 2017 are unlikely to continue working for long.</p>
 373 <p>If you have multiple versions of Visual Studio installed, <code>configure</code> will by default pick the latest. You can request a specific version to be used by setting <code>--with-toolchain-version</code>, e.g. <code>--with-toolchain-version=2015</code>.</p>
 374 <p>If you get <code>LINK: fatal error LNK1123: failure during conversion to COFF: file invalid</code> when building using Visual Studio 2010, you have encountered <a href="http://support.microsoft.com/kb/2757355">KB2757355</a>, a bug triggered by a specific installation order. However, the solution suggested by the KB article does not always resolve the problem. See <a href="https://stackoverflow.com/questions/10888391">this stackoverflow discussion</a> for other suggestions.</p>
 375 <h3 id="ibm-xl-cc">IBM XL C/C++</h3>
 376 <p>Please consult the AIX section of the <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a> OpenJDK Build Wiki page for details about which versions of XLC are supported.</p>
 377 <h2 id="boot-jdk-requirements">Boot JDK Requirements</h2>
 378 <p>Paradoxically, building the JDK requires a pre-existing JDK. This is called the &quot;boot JDK&quot;. The boot JDK does not, however, have to be a JDK built directly from the source code available in the OpenJDK Community. If you are porting the JDK to a new platform, chances are that there already exists another JDK for that platform that is usable as boot JDK.</p>
 379 <p>The rule of thumb is that the boot JDK for building JDK major version <em>N</em> should be a JDK of major version <em>N-1</em>, so for building JDK 9 a JDK 8 would be suitable as boot JDK. However, the JDK should be able to &quot;build itself&quot;, so an up-to-date build of the current JDK source is an acceptable alternative. If you are following the <em>N-1</em> rule, make sure you've got the latest update version, since JDK 8 GA might not be able to build JDK 9 on all platforms.</p>
 380 <p>Early in the release cycle, version <em>N-1</em> may not yet have been released. In that case, the preferred boot JDK will be version <em>N-2</em> until version <em>N-1</em> is available.</p>
 381 <p>If the boot JDK is not automatically detected, or the wrong JDK is picked, use <code>--with-boot-jdk</code> to point to the JDK to use.</p>
 382 <h3 id="getting-jdk-binaries">Getting JDK binaries</h3>
 383 <p>JDK binaries for Linux, Windows and macOS can be downloaded from <a href="http://jdk.java.net">jdk.java.net</a>. An alternative is to download the <a href="http://www.oracle.com/technetwork/java/javase/downloads">Oracle JDK</a>. Another is the <a href="https://adoptopenjdk.net/">Adopt OpenJDK Project</a>, which publishes experimental prebuilt binaries for various platforms.</p>
 384 <p>On Linux you can also get a JDK from the Linux distribution. On apt-based distros (like Debian and Ubuntu), <code>sudo apt-get install openjdk-&lt;VERSION&gt;-jdk</code> is typically enough to install a JDK &lt;VERSION&gt;. On rpm-based distros (like Fedora and Red Hat), try <code>sudo yum install java-&lt;VERSION&gt;-openjdk-devel</code>.</p>
 385 <h2 id="external-library-requirements">External Library Requirements</h2>
 386 <p>Different platforms require different external libraries. In general, libraries are not optional - that is, they are either required or not used.</p>
 387 <p>If a required library is not detected by <code>configure</code>, you need to provide the path to it. There are two forms of the <code>configure</code> arguments to point to an external library: <code>--with-&lt;LIB&gt;=&lt;path&gt;</code> or <code>--with-&lt;LIB&gt;-include=&lt;path to include&gt; --with-&lt;LIB&gt;-lib=&lt;path to lib&gt;</code>. The first variant is more concise, but require the include files an library files to reside in a default hierarchy under this directory. In most cases, it works fine.</p>
 388 <p>As a fallback, the second version allows you to point to the include directory and the lib directory separately.</p>
 389 <h3 id="freetype">FreeType</h3>
 390 <p>FreeType2 from <a href="http://www.freetype.org/">The FreeType Project</a> is not required on any platform. The exception is on Unix-based platforms when configuring such that the build artifacts will reference a system installed library, rather than bundling the JDK’s own copy.</p>
 391 <ul>
 392 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libfreetype6-dev</code>.</li>


 480 <h4 id="configure-arguments-for-native-compilation">Configure Arguments for Native Compilation</h4>
 481 <ul>
 482 <li><code>--with-devkit=&lt;path&gt;</code> - Use this devkit for compilers, tools and resources</li>
 483 <li><code>--with-sysroot=&lt;path&gt;</code> - Use this directory as sysroot</li>
 484 <li><code>--with-extra-path=&lt;path&gt;[;&lt;path&gt;]</code> - Prepend these directories to the default path when searching for all kinds of binaries</li>
 485 <li><code>--with-toolchain-path=&lt;path&gt;[;&lt;path&gt;]</code> - Prepend these directories when searching for toolchain binaries (compilers etc)</li>
 486 <li><code>--with-extra-cflags=&lt;flags&gt;</code> - Append these flags when compiling JDK C files</li>
 487 <li><code>--with-extra-cxxflags=&lt;flags&gt;</code> - Append these flags when compiling JDK C++ files</li>
 488 <li><code>--with-extra-ldflags=&lt;flags&gt;</code> - Append these flags when linking JDK libraries</li>
 489 </ul>
 490 <h4 id="configure-arguments-for-external-dependencies">Configure Arguments for External Dependencies</h4>
 491 <ul>
 492 <li><code>--with-boot-jdk=&lt;path&gt;</code> - Set the path to the <a href="#boot-jdk-requirements">Boot JDK</a></li>
 493 <li><code>--with-freetype=&lt;path&gt;</code> - Set the path to <a href="#freetype">FreeType</a></li>
 494 <li><code>--with-cups=&lt;path&gt;</code> - Set the path to <a href="#cups">CUPS</a></li>
 495 <li><code>--with-x=&lt;path&gt;</code> - Set the path to <a href="#x11">X11</a></li>
 496 <li><code>--with-alsa=&lt;path&gt;</code> - Set the path to <a href="#alsa">ALSA</a></li>
 497 <li><code>--with-libffi=&lt;path&gt;</code> - Set the path to <a href="#libffi">libffi</a></li>
 498 <li><code>--with-jtreg=&lt;path&gt;</code> - Set the path to JTReg. See <a href="#running-tests">Running Tests</a></li>
 499 </ul>
 500 <p>Certain third-party libraries used by the JDK (libjpeg, giflib, libpng, lcms and zlib) are included in the JDK repository. The default behavior of the JDK build is to use this version of these libraries, but they might be replaced by an external version. To do so, specify <code>system</code> as the <code>&lt;source&gt;</code> option in these arguments. (The default is <code>bundled</code>).</p>
 501 <ul>
 502 <li><code>--with-libjpeg=&lt;source&gt;</code> - Use the specified source for libjpeg</li>
 503 <li><code>--with-giflib=&lt;source&gt;</code> - Use the specified source for giflib</li>
 504 <li><code>--with-libpng=&lt;source&gt;</code> - Use the specified source for libpng</li>
 505 <li><code>--with-lcms=&lt;source&gt;</code> - Use the specified source for lcms</li>
 506 <li><code>--with-zlib=&lt;source&gt;</code> - Use the specified source for zlib</li>
 507 </ul>
 508 <p>On Linux, it is possible to select either static or dynamic linking of the C++ runtime. The default is static linking, with dynamic linking as fallback if the static library is not found.</p>
 509 <ul>
 510 <li><code>--with-stdc++lib=&lt;method&gt;</code> - Use the specified method (<code>static</code>, <code>dynamic</code> or <code>default</code>) for linking the C++ runtime.</li>
 511 </ul>
 512 <h3 id="configure-control-variables">Configure Control Variables</h3>
 513 <p>It is possible to control certain aspects of <code>configure</code> by overriding the value of <code>configure</code> variables, either on the command line or in the environment.</p>
 514 <p>Normally, this is <strong>not recommended</strong>. If used improperly, it can lead to a broken configuration. Unless you're well versed in the build system, this is hard to use properly. Therefore, <code>configure</code> will print a warning if this is detected.</p>
 515 <p>However, there are a few <code>configure</code> variables, known as <em>control variables</em> that are supposed to be overriden on the command line. These are variables that describe the location of tools needed by the build, like <code>MAKE</code> or <code>GREP</code>. If any such variable is specified, <code>configure</code> will use that value instead of trying to autodetect the tool. For instance, <code>bash configure MAKE=/opt/gnumake4.0/bin/make</code>.</p>
 516 <p>If a configure argument exists, use that instead, e.g. use <code>--with-jtreg</code> instead of setting <code>JTREGEXE</code>.</p>
 517 <p>Also note that, despite what autoconf claims, setting <code>CFLAGS</code> will not accomplish anything. Instead use <code>--with-extra-cflags</code> (and similar for <code>cxxflags</code> and <code>ldflags</code>).</p>
 518 <h2 id="running-make">Running Make</h2>
 519 <p>When you have a proper configuration, all you need to do to build the JDK is to run <code>make</code>. (But see the warning at <a href="#gnu-make">GNU Make</a> about running the correct version of make.)</p>
 520 <p>When running <code>make</code> without any arguments, the default target is used, which is the same as running <code>make default</code> or <code>make jdk</code>. This will build a minimal (or roughly minimal) set of compiled output (known as an &quot;exploded image&quot;) needed for a developer to actually execute the newly built JDK. The idea is that in an incremental development fashion, when doing a normal make, you should only spend time recompiling what's changed (making it purely incremental) and only do the work that's needed to actually run and test your code.</p>


< prev index next >