Java Virtual Machine learning Note (i) Windows10 compiled OpenJDK8

Source: Internet
Author: User
Tags mercurial visual studio installer

Reprint please specify source address: http://www.cnblogs.com/lighten/p/5906359.html

1. Preparation of the compilation environment 1.1 JDK source download

OPENJDK is an open source project in the history of Java, this article compiles with OpenJDK8 as an example. OPENJDK's official website is: http://openjdk.java.net/, direct access to http://openjdk.java.net/install/index.html into the main interface. On the left there is a series of found source code lists, which provide two forms of download: Mercurial and bundles (6).

Mercurial is a code versioning tool, similar to SVN, git, but with fewer people. Bundles is the form of the package download, we choose this way. Currently only the JDK6 link page is available: Http://download.java.net/openjdk/jdk6. To download to jdk8, change the URL to jdk8: Http://download.java.net/openjdk/jdk8. After entering the page, click on the download on the line:

1.2 Preparing the compilation environment

Unzip the downloaded compressed package, go to the folder, click Readme-builds.html, this is the official compiler instruction manual. Read the third section Building/system setup/windows chapter. Here I follow what it says above to continue.

Compiling under Windows requires a similar UNIX environment, especially the shell, which can be built by using Cygwin or Mingw/msys. These tools that mimic the environment differ mainly in their handling of path names. Here take Cygwin as an example.

1.2.1 Cygwin installation

note Using Cygwin can cause a unique problem that ignores paths. usually the path directory of the settings on Windows is usually used; split, but Cygwin use: to split. This leads to paths such as: C:\path cannot be set by Cygwin unless/cygdrive/c/path is used to understand the Cygwin path, but only Cygwin can recognize it.

OpenJDK needs 1.7.16 or a later version of Cygwin, to www.cygwin.com download Cygwin. Description: I downloaded the 2.6.0, suggesting that my version is too old, then the heart .... In order not to repeat, it is best to download 1.7.16 version higher, but see 1.7.17 windows10 not support, heart ....

Cygwin the default installation of the tool does not include all the tools required for compilation, so you cannot choose the default installation, for which additional tools are required:

Note: The Cygwin software may conflict with other non-Cygwin software on your windows. can go to its official website of the FAQ https://cygwin.com/faq.html see if there is a solution, especially to focus on the 2.10 Https://cygwin.com/faq/faq.html#faq.using.bloda ( The link inside the readme-builds.html is invalid, I guess it should be these two addresses).

Note: There is a diffutils package missing.

The steps are as follows:

1. Click on the downloaded Setup-x86_64.exe

2. Select the second option: Download without installing, and then select the downloaded folder, encountered the problem when the Internet search, found someone recommend the use of address http://mirrors.kernel.org, I tried it, really can. The article teaches that if the next half of the network failed to deal with the failure, then to click Off, turn off the wizard program, and then follow the previous selection, repeat, directory and to be consistent, in the selection download installation package interface, for example, at this time all the default, after the disconnection should be installed, To change it to reinstall, click Download. The detailed address of the article is as follows: Http://blog.chinaunix.net/uid-20178959-id-1731456.html. Of course, there is a full installation package download method, I have not tried. Finally let it download.

3. After the download is complete, this interface will need to select the required tools:

The above package may be difficult to find here, mainly in search for the above packages. such as the first Ar.exe, if the search AR, is not found this tool, but search binutils, can be found. But actually does not show which is we need, because no name is AR, at this time we should compare the above description description, so that you determine which tool to download, left click Skip selected, the version number can appear. The category can be quickly located, but not accurate, practical, but some of the wrong. Summed up is the package-based, description to determine the target, this is functional description, package consistent, function is similar, that is the bag, category can only be used for rapid positioning, did not find to go to other category search.

After the download is complete, the installation begins, following the installation steps:

1. Open the Setup Wizard again, but this time select the third option to install from the local warehouse

2. Select the directory you want to install, and then select the directory you just downloaded the file from

3. To the installation Package selection screen, and then select Add once the above required package, click Install, you can

If the package is not correct, you should be able to download the package again and then install the package.

1.2.2 Visual Studio compliers Installation

According to the instruction manual, OpenJDK Windows Build requires VS2010 Professional Edition compilers. The installation location of the compiler and other tools is expected to be defined by the variable vs100comntools, which is set automatically by Microsoft Visual Studio Installer. The part that VS2010 needs is only part of C + +. Try to install in the default installation location, after the installation is complete, restart the computer to ensure that the environment variable vs100comntools has been set. Make sure that TMP or TEMP is also set in your Windows paths, for example: C:\temp. The other path formats are incorrect, which is correct. Assuming that the area is user-owned, you should see a different user path in these variables after the default installation.

Although only the C + + section is required, it is cumbersome to install the compiler separately, or to choose Visual Studio C + + professional or Visual Studio C + + version. This online is everywhere, casually next, after use can be deleted. Here is a relatively complete: http://www.itellyou.cn/. Just install the C + + module when you download it. Visual Studio C + + Express is not a 64-bit version. Recommend or download the Professional version.

1.2.3 FreeType Download

In fact, this package is something I see in other people's configurations and books, but it's not mentioned in the official build document. However, in the case of sample parameters mentioned in the Windows 32bit build with FreeType specified:bash./configure--with-freetype=/cygdrive/c/freetype-i586- -WITH-TARGET-BITS=32, which gives another example: Debug 64bit Build:bash./configure--enable-debug--with-target-bits=64. If you only use bash./configure configuration, the execution will be reported to require FreeType, so add this.

This is a free font rendering library, and OpenJDK's swing parts and Jconsole will be used to it. To go to its official website download: http://www.freetype.org/. The latest version is now 2.7. Direct: Https://sourceforge.net/projects/freetype/files/latest/download?source=files

2 Compiling OPENJDK

1. Unzip the downloaded FreeType and OpenJDK8 to the same root directory, it is best not to have Chinese in the directory, so as not to bring bad influence. Placed under the same path is also to wait for a good operation in the Cygwin.

2. Enter the OpenJDK8 directory via Cygwin. Some basic Linux knowledge is mentioned here. /path is the root path, and the C, D, E, F, etc disks on our windows are mounted under the/cygdrive/path. The current path is viewed through PWD, which is normally accessed under/usr/home/xxx. Directly through the CD/CYGDRIVE/D/OPENJDK to replace the drive letter and other paths, you can enter the location of OpenJDK decompression.

3. Configure the parameters and verify that: Bash./configure This is a situation where there are no parameters, and you can add--with-freetype=/cygdrive/c/freetype-i586 as mentioned above--with-target-bits= 32, compiled into a 32-bit JDK, or a--enable-debug--with-target-bits=64 64-bit JDK with debug capability. The specific parameters see the Configure Options in readme-builds.html. Enter, you will start to set the parameters, and verify that the configuration is correct, if there is an error to see the specific error message. I'm using bash./configure--with-freetype=/cygdrive/e/freetype-2.7--with-target-bits=64

4. After the configuration is successful, execute: make all to compile. If you fail to do clean, compile the information clearly, but you will not be aware of the previous configuration. Make Dist-clean is all cleared up. Make command detailed parameters or see readme-builds.html in the Make module, compile time is long, my notebook compared slag, spent two hours, it seems that can change one.

5. At the end of the compilation, you will see a build folder under the root path of the OPENJDK, which is the output path of the compilation. The Build/*/images/j2sdk-image/bin path must contain the executable file for the configured OPENJDK tool. It is necessary to test the tool Jtreg. It can be found in the http://openjdk.java.net/jtreg/URL, provides regression testing, runs commands in the warehouse (repositories): CD test && make prodict_home= ' pwd '/. /build/This has not been tested, generally as long as the compiler output directory to see the Java Javac and other commands can be.

3 errors in the compilation process

1.configure:could not find cmp!

Looked for a long time, finally found the answer on the StackOverflow, but also to install a diffutils bag. Or use that boot client, the same file directory, the URL. Just take this package down and click into the boot client. The third option is to see this package in the installation package interface with view selection not installed. Select Install.

These packages can be found on the official website: https://cygwin.com/packages/x86/diffutils/, as to how to install it has not been studied, the above method feels very convenient.

2. Your Cygwin is too old. You were running 2.6.0 (0.304/5/3), but at least Cygwin 1.7 was required. Please upgrade.

See this hint, a burst of silence. 1.7.16 is openjdk to the minimum version requirements, and I am searching for this version of the time on a Web site to see the 1.7.17 version, just want to download, found its description WINDOWS10 not support, after January 2016 version only began to support WINDOWS10. Back to the official website, see a note: 2.5.2 is the last version that supports Windows XP and Windows Server 2003, which is supported by Windows XP, and is close to the latest 2.6.0, so you should be able to use it. The official web site did not find the old version of the address, when I constantly looking for the old version of the official online https://cygwin.com/faq.html#faq.what.version saw 4.23 paragraph, the problem is that some applications are based on the old version of the DLL installed, if the use of the new version of the installation will be interrupted. The official explanation is that it depends on the meaning of the interruption. If the installation of the application requires a DLL in another location instead of the/bin directory, look at issue 4.21. If the app is installed due to an older version of the DLL in/bin, you should ask the app provider aloud. Remember, the Cygwin DLL is strictly compatible with the old version, and the new version always runs successfully, so in general you have to make sure that your version is up to date.

Viewing the specific startup steps will reveal that execution of bash./configure found that a script named Generated-configure.sh was running under the common/autoconf directory in OpenJDK. Open the script with notepad++ and search for your Cygwin is too old. Find the version information for Cygwin to begin checking on line 7211, as follows:

Comment out the above 7217-7225 lines without a version check. The problem should be in rows 7220 and 7221, and then bash again./configure ....

3.configure:error:target CPU mismatch. We are building for x86_64 but CL was for ""; Expected "x64".
There is no good way to solve the problem, because this is only a check environment settings, this issue should be small, CL.exe is detected, but why version recognition is not clear. There seems to be no problem with directly commenting out the judgment statement. If anyone knows what is going on, hope to inform.

4.configure:could not Find/cygdrive/e/plugins/freetype-2.7/lib/freetype.dll. Ignoring location.
This is the problem with FreeType not compiling. Compile it with visual Studio C + + 2010. The steps are as follows:

1) Open the Freetype.sln under the freetype/builds/windows/vc2010 with VS2010

2) Select the project right click, select Properties, the Configuration box appears, click Configuration Manager, interface such as.

3) Right-click the project and select Generate. In the FreeType directory,/objs/vc2010/x64 find the Freetype.dll file that you just generated. Create a Lib folder in the FreeType root directory and put the file in it. 32-bit is to modify the corresponding configuration on the line. In addition to DLLs, a Lib format is generated. When I see it compiling 64-bit on the web, the platform toolset uses the WINDOWSXXSDK,32 bit of v100. But there seems to be no problem in fact, let's record it first. Compile here to warn the coding problem, but there is no control, do not know the garbled phenomenon behind the problem is not.
5.e:\plugins\openjdk\hotspot/make/windows/get_msc_ver.sh: Line 69th: [:???? 80x86?? Microsoft (R) 32λc/c++????????? 16: An integer expression is required.

Here is not clear what is the cause of the code garbled or the program itself to identify the logic error? But look at the program source code is intended to test cl.exe version, set the corresponding value. Cl.exe in the VS2010 installation directory under vc\bin\ Three, run in DOS to see which version. My version is 16.00.30319.01. Then modify the openjdk\hostpot\make\windows\get_msc_ver.sh,65-73 line comment out, add the msc_ver=1600 directly, there is a description: CL version 12.00.8804 msc_ver=1200. Unfortunately I did not see 16.00, up to 15.00, according to this law changed to 1600.

4. Written in the last

In fact, the final is not completely compiled successfully, compiled to nashorn the time to report an error: Exception in thread "main" Java.lang.VerifyError:class Jdk.nashorn.internal.objects.ScriptFunctionImpl Overrides final method Setprototype. This I can not know what is the problem, to the current level can not be the same as before the wrong, the class file is also generated, the inside of what is not known (perhaps with the high version of the JDK8 to compile OpenJDK8 has a relationship), toss long enough, the first compile JDK source code, JDK Compilation is a success, is a virtual machine to learn to take the first step. Perhaps after learning more deeply, once again compile, may not so knock down hope. Finally, if a friend knows the cause of the problem or can explain why the console compiled output garbled is due to what aspect of coding, then thank you very much.

Java Virtual Machine learning Note (i) Windows10 compiled OpenJDK8

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.