Compile JDK in FreeBSD

Source: Internet
Author: User
Since JDK 1.1.8 and later, FreeBSD has been unable to release pre-compiled JDK software packages due to various Java authorization issues, nor has it been removed from the so-called official release.

To use the latest Java Technology on FreeBSD, You need to compile and install it by yourself in the following ways:

(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

The compilation is actually in the Linux compatibility mode of FreeBSD. Based on the Linux JDK binary, after applying the SCSL source to the BSD patch, compile the native JDK version on FreeBSD! (Wow, it's really an interface ~~~!!!)

Therefore, in the example of FreeBSD 5.4 Release, the first step is to modify the/etc/fstab file and add:

Linprocfs/compat/linux/proc linprocfs rw 0 0
 

After the restart, you can use kldstat to check whether the Linux process FileSystem has been mounted:

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
 

Next, of course, we need to upgrade to the latest ports tree:
FreeBSD # cd/usr/ports
FreeBSD # cvsup-g-L 2/root/ports-supfile
 
Then, go to the JDK port directory and use JDK 14:
FreeBSD # cd/usr/ports/java/jdk14
FreeBSD # make
 

If it is the first compilation, you should see the following prompt:
 
FreeBSD # make
Jdk-1.4.2p7_1:
The source distribution exists on your system, but due
Licensing restrictions you still need to download
Patchset, bsd-jdk14-patches-7.tar.gz, from
Http://www.eyesbeyond.com/freebsddom/java/jdk14.html.
Please place the patchset in/usr/ports/distfiles.

This indicates that we have missing some distfiles required for compilation. Fortunately, the download URL has been provided by the system. As instructed above
Capture the required files and put them here:/usr/ports/distfiles. The list of downloaded files is as follows for your reference:

  • 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


With these files, you can start to make the JDK:

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


During the make process, you will refer to the system environment to fetch the following packages on the Internet. Of course, if you have installed them, it will be great ~~~!

  • Autoconf-000227.tar.bz2
  • Automake-1.4-p6.tar.gz
  • Rpm- 3.0.6 .Tar.gz


After installing the preceding packages, make starts to return to the JDK compilation process. below is the compilation process:

 
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
... It takes a long time. Please imagine yourself as follows...


One thing to mention is that after JVM compilation, make will talk about some basic Java
The library uses javac as make and jar as packing. This takes a longer time... please wait...

After compilation, the system returns to the prompt and can make install... so happy ~~~


FreeBSD # make install
==> Installing for jdk-1.4.2p7_1
Jdk-1.4.2p7_1 depends on executable: javavm-found
... Skip...
=> Attempting to fetch from ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles.
Urw-fonts.tar.gz 100% of 1508 kB 8099 Bps 00 m 00 s
... Skip...
==> Registering installation for urwfonts-1.0
==> Returning to build of jdk-1.4.2p7_1
... Skip...
==> 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 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
Ports terminated ded 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 #


 
The next step is the general, make clean, make distclean, delete unwanted distfiles!
But do not forget to set the JAVA_HOME and CLASSPATH environment variables for Java, and you can see the Java version information:

 
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)

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.