Tuesday, January 24, 2012

Install OpneJDK7 on FreeBSD

FreeBSD deals many kind of JDKs. But, at the time of writing this article, OpenJDK7 is the only one that are ready for Java7. So that I introduce the way to install OpneJDK7 on FreeBSD.

Edit /etc/make.conf for OpenJDK7

Add these definitions to /etc/make.conf:
JAVA_VENDOR=openjdk
JAVA_VERSION=1.7
BOOTSTRAPJDKDIR=/usr/local/openjdk7
JAVA_PREFERRED_PORTS=JAVA_PORT_NATIVE_OPENJDK_JDK_1_7

Install via packages (mandatory)

# pkg_add -r openjdk7
That's all. Let's check the output of java -version command.

Install via ports (option)

If we want to install openjdk7 via ports, however, we must prepare for another JDK to be installed. In this article, I suggest to install openjdk7 via packages(above) at first, then install openjdk7 via ports.
# pkg_add -r openjdk7
# cd /usr/ports/java/openjdk7
# make install clean
# pkgdb -F
Let's check again java -version command.

3 comments:

Kavitha H Yogaraj said...

Hi

I'm a newbie to freebsd, I could install java and run in ubuntu but not in freeBSD.

When I use this command pkg_add -r openjdk7
I get this error
Error: Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.0-release/Latest/openjdk7.tbz: File unavailable (e.g., file not found, no access)
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.0-release/Latest/openjdk7.tbz' by URL

And then, when I try to mention the site name
PACKAGESITE=ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-9-stable/ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.1-release//java/openjdk-7.9.05_1.tbz
I again get invalid command error.

Could you please help me in installing java in FreeBSD?

I even want to run java web application headless.

Youhei Kondou said...

Just use this URI:
ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.1-release/

Zsolt Kiss said...

how to change URL

Post a Comment