Verified and Tested 08/18/15

Introduction

If you had the option to choose between a base model car or a fully loaded model, which one will you choose? Both cars will take you from point A to point B, but with the fully loaded car you have additional features that can make rush hour a chill hour. Well, that’s the same concept when we take a closer look at Java. There are two standard types of installations, JRE (Java Runtime Environment) and JDK (Java Development Kit). As the base model car, JRE enables the ability to create Java Applications for different types of deployments using minimal core tools to accomplish the task. JDK is a fully loaded Development Kit that has everything that JRE has plus additional resources to create/secure Applications and Applets.

This how-to will take you through the installation of JRE and JDK on your FreeBSD server.

Prerequisites

You need a FreeBSD server that is configured with a static IP address. If you do not have a server already, you can set up a FreeBSD server with one of Atlantic.Net’s award winning VPS hosting solutions in under 30 seconds.

Before we begin, Let’s make sure that your server is fully up-to-date so we can complete the preparation.

freebsd-update fetch 
freebsd-update install

After your server has been fully updated you will need to know what version of Java is currently installed (or if it is installed at all), with the following command:

java -version

Once you have verified if Java is installed or not, run the following command to search the version and type of Java that you would like to install.

pkg search ^openjdk

You now have the option to choose any of the available packages. In this case the latest package is version 8.

openjdk-7.80.15_1,1
openjdk-jre-7.80.15_1,1
openjdk6-b36,1
openjdk6-jre-b36,1
openjdk8-8.51.16
openjdk8-jre-8.51.16

Install Java Open JRE on FreeBSD

Select your package version, and install it with one of the following commands:

pkg install openjdk6-jre
pkg install openjdk-jre
pkg install openjdk8-jre

Install Java Open JDK on FreeBSD

Select your package version, and install it with one of the following commands:

pkg install openjdk6
pkg install openjdk
pkg install openjdk8

Once you have installed your package, you will see the following message on your screen.

This OpenJDK implementation requires fdescfs(5) mounted on /dev/fd and
procfs(5) mounted on /proc.

If you have not done it yet, please do the following:
        mount -t fdescfs fdesc /dev/fd
        mount -t procfs proc /proc
To make it permanent, you need the following lines in /etc/fstab:

        fdesc   /dev/fd         fdescfs         rw      0       0
        proc    /proc           procfs          rw      0       0

To finalize the installation, type the following commands just like the message states.

mount -t fdescfs fdesc /dev/fd
mount -t procfs proc /proc

Then to make the changes permanent use your text editor to edit the fstab file:

nano /etc/fstab

Add the following lines to the fstab file:

fdesc           /dev/fd         fdescfs         rw      0       0
proc            /proc           procfs          rw      0       0

So all changes take effect, we must then refresh the system with the following command:

rehash

What Next?

Congratulations! You now have a successfully installed Java on your FreeBSD server. Thank you for following along and feel free to check back with us for further updates or learn more about our reliable virtual private servers.