自从JDK 1.1.8后,FreeBSD 因为在 Java 授权上的种种问题,已经不能发布预编译的 JDK 软件包,也没有了所谓的 Official Release 了 。
现在要在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 linprocfs rw 0 0 |
重新启动后,可以用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. |
将所需要的档案抓下来,并放到这里:/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- 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用javac作make,然后用jar作packing,这样需要的时间更长...请再耐心等待...
编译完成后,系统回到提示符下,可以make install了...好高兴啊~~~
FreeBSD# make install
|
接下来就是常规的,make clean, make distclean,删除不想要的distfiles了!
不过不要忘记了给Java设定JAVA_HOME和CLASSPATH的环境变量,最后就可以看到Java的版本信息:
FreeBSD# cd /usr/local/jdk 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) |