Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS 6.5Compiler openJDK and its problems

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Go into Java1 centOS 6.5.Compiling openJDK

During this operation, the author installed and configured the linux virtual machine three times. For the first time, it was all treading on the pit. The second time is also stepped on part of the pit, especially 2.9 this pit, directly led to my third time, but finally succeeded! Featured this blog, I hope it will be helpful to you!

Note: please pay attention to the version number of the relevant installation files! Otherwise, there is a risk of failure! I have uploaded the relevant file resources I used to 51CTO. The download address is at the end of the article!

1.1 linux environment preparation

Linux environment preparation: Oracle VMware virtualBox 11.0.0 and install CentOS 6.5

(the installation method refers to the online information)

CentOS is an enterprise Linux distribution based on the freely available source code provided by Red Hat Linux.

This compilation uses 64-bit OS, compilation is also 64-bit JDK, 1G of memory, 20g of hard disk

Implementation process reference

(read README and README-builds.html)

README-builds.html contains detailed installation information, it is best to read it in its entirety.

Minimize installation and installation of basic software packages (can be omitted)

Use minimized (Minimal) installation during installation

[root@localhost~] # cat / etc/RedHat-release

CentOS release 6.5 (Final)

[root@localhost~] # uname-m

X86_64

[root@localhost~] # uname-r

2.6.32-431.el6.x86_64

Configure update source

Cd/etc/yum.repos.d/

Curl http://mirrors.163.com/.help/CentOS6-Base-163.repo > CentOS6-Base-163.repo

Currently, wget is not available

# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

MvCentOS-Base.repo CentOS-Base.repo.bak

MvCentOS6-Base-163.repo CentOS-Base.repo

Yum makecache

Yum-ygroupinstall 'base'

Yum-y installmake

Create three directories:

# mkdir/usr/tools/

# mkdir / usr/java/

# mkdir / usr/jdks/

Upload file tool: Xftp (default) or install lrzsz

Uninstall jdk that comes with linux

After the installation is complete, enter the linux system:

Jdk that comes with linux

If OpenJDK is installed, you can uninstall it using the following methods:

Rpm-qa | grepjava

Rpm-e-- nodepsjava-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

Rpm-e-- nodepsjava-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

Note:

Rpm-e xxx / / normal delete mode

Rpm-e-- nodeps xxx / / forcefully delete mode. If you use the above command to delete other dependent files, you can delete them forcefully with this command, which may lead to unexpected errors and system damage.

1.3 install JDK1.6

The original text in README-builds.html is posted below:

Bootstrap JDK

All OpenJDK builds require access to thepreviously released JDK 6, this is often called a bootstrap JDK. The JDK 6binaries can be downloaded from Sun's JDK 6 download site. For buildperformance reasons is very important that this bootstrap JDK be made availableon the local disk of the machine doing the build. You should always setALT_BOOTDIR to point to the location of the bootstrap JDK installation, this isthe directory pathname that contains a bin, lib, and include It's also a goodidea to also place its bin directory in the PATH environment variable, althoughit's not required.

Configure the boot JDK.

The snippet from "in depth understanding the Java Virtual Machine":

It is necessary to prepare a JDK of more than 6u14 (JDK1.6 and above), because the various components of openJDK (Hotspot, JDK API, JAXWS, JAXP... Some are written in C++, and much of the code is implemented in Java itself, so compiling this Java code requires an available JDK, which is officially called "Bootstrap JDK". Bootstrp JDK must be JDK6 update 14 or later!

Jdk1.6 must be installed, because in the compilation process, you need to rely on jdk1.6 to initialize the VM virtual machine and compile some java files!

Special note: jdk and openJDK are not the same, specific description please Baidu!

Jdk1.6 download address: http://down.51cto.com/data/2306446

Upload the downloaded jdk1.6 to the / usr/java/ directory:

Add executable permissions to the user

# chmod + x jdk-6u45-linux-x64.bin or # chmod 755jdk-6u45-linux-x64.bin

#. / jdk-6u45-linux-x64.bin

# ll

Configure environment variables, and then test:

# java-version

[note: if you install JDK1.7 or above, you will report an error when performing the final make operation: see: 2.6]

1.4download openJDK 1.71.4.1 recommended download openJDK method

OpenJDK download address: http://www.java.net/download/openjdk/jdk7u6/promoted/b24/openjdk-7u6-fcs-src-b24-28_aug_2012.zip

Use the Xftp plug-in to upload the downloaded openJDK and upload it to the / usr/jdk/ directory

# unzip openjdk-7u6-fcs-src-b24-28_aug_2012.zip

Then delete the original file: (or do not delete the standby)

[the method of installing openJDK1.7 is not recommended, please refer to: 2.1]

1.5 compile openJDK-related dependency packages

Note that you must first go back to the root directory:

[root@openjdk usr] # cd /

1.5.1 install prerequisites:

Yum-y install alsa-lib-devel

Yum-y install cups-devel

Yum-y install libXi-devel

Yum-y install gccgcc-c++

Yum-y install libX*

1.5.2 install freetype

Freetype download address: http://sourceforge.net/projects/freetype/files/freetype2/

Downloaded freetype-2.5.5 resource address: http://down.51cto.com/data/2306445

Enter the tools directory:

# cd / usr/tools/

[note: there will be version compilation errors when installing freetype! Freetype-2.5.2 was installed for the first time, but the compilation failed! See 2.2. Finally chose freetype2.5.5]

1.5.2.1 method 1: (not recommended, the speed is too slow)

Install the freetype2.5.5 version:

/ / the download address may change. Fill in the path and relevant version according to your own needs.

[root@openjdk tools] # wget https://www.sourceforge.net/projects/freetype/files/freetype2/2.5.5/freetype-2.5.5.tar.gz

Or wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.5.tar.gz

Note: there may be situations where the download is not available or the speed is very slow. Recommended way two!

Error report:

Tar-xvf freetype-2.5.5.tar.gz

Cd freetype-2.5.5

. / configure

Make

Make install

Success!

Or:

Freetype can also be installed as yum: (not attempted)

Yum install gcc gcc-c++ freetype-develglib2-devel cairo-devel

1.5.2.2 method II

Freetype-2.5.5.tar.gz download address: http://sourceforge.net/projects/freetype/files/freetype2/

Download freetype2.5.5 manually:

Use Xftp to upload the file to the / usr/tools/ directory:

Decompress:

# tar-xvf freetype-2.5.5.tar.gz

# cd freetype-2.5.5

#. / configure

# make

# make install

1.5.3 install ant

Ant download address: http://archive.apache.org/dist/ant/binaries/

Downloaded apache-ant-1.9.6 resource address: http://down.51cto.com/data/2306443

# cd / application/tools/

The same two ways:

Method 1: (download speed is a little slow)

# wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.6-bin.zip

# unzip apache-ant-1.9.6-bin.zip

Method 2:

Download the ant source code from the official website, and then upload it to the linux system using Xftp:

# unzip apache-ant-1.9.6-bin.zip or tar-xvfapache-ant-1.9.6-bin.tar.gz

# ln-s / usr/tools/apache-ant-1.9.6/bin/ant/usr/bin/ant

/ / ln-s establish a synchronous link for a file or directory in another location

After the link, the ant command is available!

1.5.4 check the above configuration:

1.6 compile 1.6.1 set environment variable 1.6.1.1 official configuration: (not recommended)

Note: the relevant parameters have not been modified.

# set language

Export

Export ALT_BOOTDIR=/usr/lib/jvm/jdk1.7.0/

# allow automatic download of dependent packages

Export ALLOW_DOWNLOADS=true

# using precompiled header files, without this compilation will be slower

Export USE_PRECOMPILED_HEADER=true

# content to be compiled

Export BUILD_LANGTOOLS=true

Export BUILD_JAXP=true

Export BUILD_JAXWS=true

Export BUILD_CORBA=true

Export BUILD_HOSTPOT=true

Export BUILD_JDK=true

# version to be compiled

Export SKIP_DEBUG_BUILD=false

Export SKIP_FASTDEBUG_BUILD=true

Export DEBUG_NAME=debug

# set it to FALSE to avoid partial build such as javaws and browser Java plug-ins

BUILD_DEPLOY=false

# setting it to false will not build the installation package. Because there are some strange dependencies in the installation package

# but even if you don't build it, you already have a full JDK image, so you still don't need to build it.

BUILD_INSTALL=false

# storing compilation results

Export ALT_OUTPUTDIR=/home/lzl/openjdk/build

Unset CLASSPATH

Unset JAVA_HOME

Make 2 > & 1 | tee $ALT_OUTPUTDIR/build.log

1.6.1.2 actual configuration

Unset CLASSPATH

Unset JAVA_HOME

Export

Export ALT_BOOTDIR=/usr/java/jdk1.6.0_45 # pre-installed jdk7 directory

ExportANT_HOME=/usr/tools/apache-ant-1.9.6 # ant installation directory

ExportALT_FREETYPE_HEADERS_PATH=/usr/local/include/freetype2 # freetype2 header file installation directory

ExportALT_FREETYPE_LIB_PATH=/usr/local/lib # freetype2 lib directory

Export ARCH_DATA_MODEL=64 # 64 bit

Export SKIP_DEBUG_BUILD=false

Export SKIP_FASTDEBUG_BUILD=true

Export DEBUG_NAME=debug

# output path

Export ALT_OUTPUTDIR=/usr/openjdk

Configuration complete, effective!

# source / etc/profile

[an error was encountered while configuring environment variables: see: 2.3]

1.6.2 make sanity check

Check whether the environment is configured with OK and compiled jdk source code

# cd / usr/jdk/

# cd openjdk

# pwd

# make sanity

Success!

[when I got to this point for the first time, I made the same conceptual mistake as jdk and openJDK, see: 2.4]

1.6.3 make compilation

If you have compiled before, do clean first:

# make clean

# make all

Finally: see the success!

[the first time make all encountered an error due to a problem with the jdk version, see: 2.5]

Repeat: make clean and make all

[the second make all encountered an error due to a problem with the CurrentDate.properties time profile, see: 2.7and 2.8]

Repeat: make clean and make all

[error of insufficient hard disk space, see: 2.9]

1.7 run the virtual machine compiled by yourself 1.7.1 mode 1 (recommended)

Then check the JDK version after the compilation is successful:

Because the installation output path is configured, go to the configuration path:

Enter the usr/openjdk/bin directory and enter. / java-version

At this point, compiling openJDK is a success!

[note: if the output path # exportALT_OUTPUTDIR=/usr/openjdk; is not configured when configuring environment variables, a build directory will be created to store output data under the openjdk directory by default, and it will become:

Enter the openjdk/build/bin directory and enter. / java-version

]

1.7.2 method II

Enter the directory

(by default: the path is: / openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2)

The hotspot directory after configuring the output path is:

[root@openjdkhotspot] # cd / usr/openjdk/hotspot/

# cd outputdir/linux_amd64_compiler2

# ll

There are several compiled versions at the optimization level:

Go to the product directory:

# cd product/

# ll

Here, under env.sh configuration, the environment variable points to the shared library: (the path adjusts the configuration according to the actual situation)

LD_LIBRARY_PATH=.:$ {JAVA_HOME} / jre/lib/amd64/native_threads:$ {JAVA_HOME} / jre/lib/amd64:/opt/openJDKroom/openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product

Export LD_LIBRARY_PATH

The full contents of my file are posted below:

# Generated by / usr/jdk/openjdk/hotspot/make/linux/makefiles/buildtree.make

#: ${JAVA_HOME:=/usr/java/jdk1.6.0_45}

JAVA_HOME=/usr/openjdk/j2sdk-p_w_picpath # this configuration depends on the situation: the default is: / usr/openjdk/build/linux-amd64/j2sdk-p_w_picpath

CLASSPATH=.:$ {JAVA_HOME} / jre/lib/rt.jar:$ {JAVA_HOME} / jre/lib/i18n.jar

HOTSPOT_BUILD_USER= "root inhotspot"

Export JAVA_HOME CLASSPATHHOTSPOT_BUILD_USER

# add

For the path following #, the default configuration is / usr/openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product

LD_LIBRARY_PATH=.:$ {JAVA_HOME} / jre/lib/amd64/native_threads:$ {JAVA_HOME} / jre/lib/amd64:/usr/openjdk/hotspot/outputdir/linux_amd64_compiler2/product

Export LD_LIBRARY_PATH

Do the following:

# source. / env.sh

# cd..

Go back to the previous directory and enter: / usr/openjdk/hotspot/outputdir/linux_amd64_compiler2/jvmg

# cd jvmg/

#. / test_gamma

Run successfully!

1.8 run HotSpot on NetBeans compilation

Reference blog: http://www.cnblogs.com/zyx1314/p/5638596.html

2 step on pit 2.1 it is not recommended to install openJDK1.7 (only if you use centOS):

[recommended for ubuntu virtual machine] the specific reference URL is as follows:

Http://openjdk.java.net/install/index.html

$sudo apt-getinstall openjdk-7-jre

Reason: CentOS's software installation tool is not apt-get, it's yum.

Yum (YellowdogUpdater Modified) is a Linux software that integrates and finds, installs, updates and removes programs.

# yum install xxx so... .

2.1.1 question

No package openjdk-7-jre available. Error:Nothing to do

[when solving this series of problems: please back up the libperl.so (required): if an error is reported later:

: error while loading shared libraries:/usr/lib64/perl5/CORE/libperl.so: file too short

At this point, libperl.so backup files, restore can, the operation caused the libperl.so to be empty, so after the restore. After the solution is completed, the relevant components can be used normally. ]

View the openjdk installation package on the yum service:

[root@openjdk java] # yum list | grepopenjdk

Update yum warehouse: (use with caution! Don't yumupdate casually, the consequence will sometimes cause the system not to start, because it will update your kernel, after stopping, enter the system, preferably yum clean all)

[root@openjdk java] # yum-y update

* * (waiting for the next hour. ) you can skip this step in practice!

List the package names related to yum through the lookup parameters of openjdk:

[root@openjdk java] # yum search openjdk

Install the version that exists in the yum repository:

[root@openjdk java] # yum install java-1.7.0-openjdk.x86_64

Test whether the installation is successful:

2.2 install freetype2.5.2 (version error)

Freetype-2.5.2.tar.gz download address: http://sourceforge.net/projects/freetype/files/freetype2/

Download freetype2.5.2 manually:

Use Xftp to upload the file to the / usr/tools/ directory:

Decompress:

Tar-xvf freetype-2.5.2.tar.gz

Cd freetype-2.5.2

. / configure

Error: solution:

Enter: [root@openjdk freetype-2.5.2] # cd builds/unix/

[root@openjdk unix] #. / configure

Go back to the freetype-2.5.2 directory and execute make:

Cd..

Cd..

Make

[root@openjdk freetype-2.5.2] # make

Config.mk:25: builds/unix/unix-def.mk: there is no such file or directory

Config.mk:26: builds/unix/unix-cc.mk: there is no such file or directory

Make: * there are no rules to create the target "builds/unix/unix-cc.mk". Stop it.

I looked for it on the Internet. There is no relevant solution:

"after downloading several versions of freeType and installing them in source code (configure/ make & & make install), it never works." similarly afflicted people pity each other

After taking a look at the permissions, you are ready to give root permission to try again: and create the two files manually.

It won't solve the problem. Delete freetype-related materials.

Change to version 2.5.5, solve the problem!

# make install

2.3 configure environment variables to report errors

Description: the first time configuration compilation, the installation is jdk1.7, negligible, and this error has nothing to do with!

Error report:

There must be something wrong with profile configuration file writing:

General reasons for export `= 'not a valid identifier

The reason is that in the modified / etc/profile file

Added spaces!

Remove the spaces and solve the problem!

2.4 make sanity error

[report an error:

Make:*** No rule to make target `sanity'. Stop.

The root cause of the above problem is that after the project changes the path or the folder name in it, the previously generated .o.d file will not be recompiled when it is compiled again, thus causing the problem. The root cause solution is to delete the compiled obj folder. And then recompile it.

Mainly because the previous did not download openJDK, or directly use the jdk to compile! Forgive my ignorance! After reprocessing:

Success!

2.5 make all error

Error: jdk1.7 encountered an error while initializing VM!

Using java runtime at:/usr/java/jdk1.7.0_75/jre

Error occurred duringinitialization of VM

The solution to this problem: http://stackoverflow.com/questions/26804355/cannot-compile-openjdk7-source-code-on-centos6-5

Download and install Oracle JDK 1.6.0_45and set it to "ALT_BOOTDIR" and "ALT_JDK_IMPORT_PATH", please do not use OpenJDK1.7

Solution:

Change the JDK version, reconfigure the jdk1.6.0_45 version, and execute # make (Ref. 2.6)

2.6 change the JDK version

Delete the jdk1.7 directory and files in the directory

Install jdk1.6

Upload the downloaded jdk1.6 to the / usr/java/ directory:

Add executable permissions to the user

# chmod + x jdk-6u45-linux-x64.bin or # chmod 755jdk-6u45-linux-x64.bin

#. / jdk-6u45-linux-x64.bin

# ll

Change the configuration of environment variables

Save effective

# source / etc/profile

Enter the / usr/jdk/openjdk directory and execute 1.5.3

2.7 Error: time is more than 10years from present: 1136059200000

Solution reference blog: http://www.bubuko.com/infodetail-1306571.html

Data.temp\

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report