Install Java on FreeBSD

Contents
Introduction
Install a JDK
JAVA_HOME
Check the version
Ports vs packages

Introduction

FreeBSD ships OpenJDK as a binary package and as a port. The package installs in seconds; the port lets you tune build options.

Install a JDK

From binary packages:

sudo pkg install -y openjdk17

Or build from ports:

cd /usr/ports/java/openjdk17 && sudo make install clean

JAVA_HOME

Point build tools at the JDK. The package layout lives under /usr/local/openjdk17:

export JAVA_HOME=/usr/local/openjdk17

Add the line to ~/.shrc or ~/.bashrc to keep it across logins.

Check the version

java -version

Both java and javac must report the installed release.

Ports vs packages

Prefer the binary package for speed; build the port only when you need non-default options (a different CA bundle, extra charset support). After major FreeBSD upgrades, rebuild or reinstall the JDK — old binaries against a new libc fail in creative ways.

Related articles
Development на Java
Установка Java
Install Java on Linux
Install Java on FreeBSD
Install Java on macOS
Install Java on OpenBSD
Intellij
Компиляция и запуск Java кода
final
switch
Определить тип переменной
Генератор случайных чисел
Импорт из других классов
Maven
JUnit
Banner image

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: