`

FreeBSD中编译JDK

 
阅读更多
自从JDK 1.1.8后,Sun害怕FreeBSD扩大导致自家的Solaris的份额下降,于是终止了FreeBSD Project
的官方native版本的port发布!现在要在FreeBSD上使用最新的Java技术,需要通过下面的方式进行安装:

(1) FreeBSD + Linux compatibility enable + Linux Process FileSystem mounted
(2) Linux Platform - Java(TM) 2 SDK, self-extracting file
(3) SCSL (Sun Community Source Licensing) Source
-SCSL Source
-SCSL Binaries - needed to complete source build
-Mozilla Binaries
(4) BSD Java porting patchsets

编译实际上是在FreeBSD的Linux兼容模式下,以Linux JDK Binary为基础,将SCSL Source打上BSD的patch后,在FreeBSD上面编译出native的JDK版本!(哇塞,真是拗口~~~!!!)

所以,以FreeBSD 5.4 Release为例子,我们第一步要做的就是修改 /etc/fstab 这个文件, 新增:

linprocfs /compat/linux/proc inprocfs rw 00




重新启动后,可以用kldstat查看是否已经mount上了Linux process FileSystem:

FreeBSD# kldstat
Id Refs Address Size Name
1 10 0xc0400000 5dde24 kernel
2 14 0xc09de000 56270 acpi.ko
3 1 0xc1803000 6000 linprocfs.ko
4 1 0xc180c000 17000 linux.ko

接下来,当然是要升级到最新的ports tree了:

FreeBSD# cd /usr/ports
FreeBSD# cvsup -g -L 2 /root/ports-supfile

然后,进入到JDK的port目录下,我使用的是JDK14:

FreeBSD# cd /usr/ports/java/jdk14
FreeBSD# make

如果是初次编译,应该会看到下面的提示:

FreeBSD# make
===> jdk-1.4.2p7_1 :
The source distribution exists on your system, but due to
licensing restrictions you still need to download the
patchset, bsd-jdk14-patches-7.tar.gz, from
http://www.eyesbeyond.com/freebsddom/java/jdk14.html.
Please place the patchset in /usr/ports/distfiles.
这说明我们少了一些编译所需要的distfiles,所幸的是系统已经给出了下载的网址,按照上面的提示,一一
将所需要的档案抓下来,并放到这里:/usr/ports/distfiles,我下载的文件列表如下,供大家参考:

bsd-jdk14-patches-7.tar.gz
j2sdk-1_4_2-bin-scsl.zip
j2sdk-1_4_2-mozilla_headers-unix.zip
j2sdk-1_4_2-src-scsl.zip
j2sdk-1_4_2_09-linux-i586.bin
j2sdk-sec-1_4_2-src-scsl.zip

有了这些文件后,就可以开始对JDK进行make了:


FreeBSD# cd /usr/ports/java/jdk14
FreeBSD# make

make过程中,会参照系统环境去网上fetch下面几个package,当然,如果您已经安装了它们就太好了~~~

autoconf-000227.tar.bz2
automake-1.4-p6.tar.gz
rpm-<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"></chsdate>3.0.6.tar.gz


make
完成对上面几个package安装后,就开始返回到JDK的编译过程,下面是编译中:

Compiling /usr/ports/java/jdk14/work/hotspot/src/share/vm/oops/cpCacheKlass.cpp
Compiling /usr/ports/java/jdk14/work/hotspot/src/share/vm/oops/cpCacheOop.cpp
Compiling /usr/ports/java/jdk14/work/hotspot/src/share/vm/utilities/debug.cpp
Compiling /usr/ports/java/jdk14/work/hotspot/src/share/vm/code/debugInfo.cpp
Compiling /usr/ports/java/jdk14/work/hotspot/src/share/vm/code/debugInfoRec.cpp
Compiling /usr/ports/java/jdk14/work/hotspot/src/cpu/i486/vm/debug_i486.cpp
... 时间很长,以下请大家自我想象...

需要提到一点的是,编译完JVM后,因为我选择的是默认的安装方法,所以make还会去讲一些Java基本的
library
javacmake,然后用jarpacking,这样需要的时间更长...请再耐心等待...

编译完成后,系统回到提示符下,可以make install...好高兴啊~~~


FreeBSD# make install
===> Installing for jdk-1.4.2p7_1
===> jdk-1.4.2p7_1 depends on executable: javavm - found
... 跳过 ...
=> Attempting to fetch from ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/.
urw-fonts.tar.gz 100% of 1508 kB 8099 Bps <chmetcnv w:st="on" unitname="m" sourcevalue="0" hasspace="False" negative="False" numbertype="1" tcsc="0"></chmetcnv>00m00s
... 跳过 ...
===> Registering installation for urwfonts-1.0
===> Returning to build of jdk-1.4.2p7_1
... 跳过 ...
===> Registering installation for jdk-1.4.2p7_1
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/jdk<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"></chsdate>1.4.2/jre/lib/i386/native_threads/libhpi.so
/usr/local/jdk1.4.2/jre/lib/i386/client/libjvm.so
/usr/local/jdk1.4.2/jre/lib/i386/libnio.so
/usr/local/jdk1.4.2/jre/lib/i386/libdt_socket.so
/usr/local/jdk1.4.2/jre/lib/i386/server/libjvm.so
/usr/local/jdk1.4.2/jre/javaws/javawsbin

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://www.freebsd.org/java/
FreeBSD#


接下来就是常规的,make clean make distclean,删除不想要的distfiles了!
不过不要忘记了给Java设定JAVA_HOMECLASSPATH的环境变量,最后就可以看到Java的版本信息:


FreeBSD# cd /usr/local/jdk<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"></chsdate>1.4.2/bin
FreeBSD# java -version
java version "1.4.2-p7"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-p7-root_06_oct_2005_21_31)
Java HotSpot(TM) Client VM (build 1.4.2-p7-root_06_oct_2005_21_31, mixed mode)


FreeBSD# cd /usr/local/jdk<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"></chsdate>1.4.2/bin
FreeBSD# java -version
java version "1.4.2-p7"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-p7-root_06_oct_2005_21_31)
Java HotSpot(TM) Client VM (build 1.4.2-p7-root_06_oct_2005_21_31, mixed mode)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics