Hello friends, the goal of this tutorial is for you to learn how to install Java on FreeBSD 12 so you can enjoy it and use it for different purposes.
We already know that Java is one of the most used programming languages in the world. Besides this, many applications need Java to run and therefore many people need it.
On the other hand, many people use FreeBSD 12 as an operating system for a server. Many dedicated server applications need Java to run as well as to serve applications.
So, let us do it.
Install Java on FreeBSD 12
For this tutorial you need to run sudo. So this program has to be enabled and working properly. For that, read our tutorial about it:
Once you have done it, you can continue with the post.
Next is bscar Java in the official FreeBSD 12 repositories.
:~$ sudo pkg search openjd
bootstrap-openjdk11-18.104.22.168.1 Java Development Kit 11
bootstrap-openjdk6-r450701 Java Development Kit 6
bootstrap-openjdk8-r450802 Java Development Kit 8
openjdk-7.161.01,1 Java Development Kit 7
openjdk-jre-7.161.01,1 Java Runtime Environment 7
openjdk11-11.0.5+10.1 Java Development Kit 11
openjdk12-12.0.2+10.3_1 Java Development Kit 12
openjdk13-13.0.1+9.1 Java Development Kit 13
openjdk8-8.232.09.1_1 Java Development Kit 8
openjdk8-jre-8.232.09.1_1 Java Runtime Environment 8
rxtx-openjdk8-2.2p2_4 Native interface to serial ports in Java
In the image we can see that there are several versions of Java available, but only version 8 contains both JDK and JRE. Therefore, this is the version that we will install.
:~$ sudo pkg install openjdk8
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 27 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
Number of packages to be installed: 27
The process will require 234 MiB more space.
89 MiB to be downloaded.
Proceed with this action? [y/N]:
Once Java is installed a few more things need to be done to get it ready for work. Because this OpenJDK implementation requires fdescfs(5) mounted on /dev/fd and
procfs(5) mounted on /proc.
So, to do it, run these commands:
:~$ sudo mount -t fdescfs fdesc /dev/fd
:~$ sudo mount -t procfs proc /proc
This solves the problem temporarily, if we want to avoid running these commands every time we start the system, we have to edit the file /etc/fstab and add the following:
:~$ sudo nano /etc/fstab
fdesc /dev/fd fdescfs rw 0 0
proc /proc procfs rw 0 0
So, save the changes and close the file.
Now, you can check the Java version.
:~$ java -version
So, Java is ready for the action.
Java is a fairly popular platform and this makes it necessary for many FreeBSD 12 developers and users to run or serve applications of this type. Today you have learned how to install it without problems.
Please share this post and join our Telegram channel.