Java on Haiku

Java on Haiku

  • mdo  DigitalBox
  •   Dev
  •   December 6, 2024

Java is available on Haiku via the Open JDK package.

In case you don't find native applications corresponding to your need, Java can be a good option as it will open the door to a new ecosystem.

We will review in the article how to install Java and what it can bring to Haiku.

Installation

The OpenJDK is available in version 17 for Haiku which has been released end of year 2021.

Please note, it's not the latest version, as the last stable release available is version 23 published end of 2024 according to the official OpenJDK website.

In order to install Java from HaikuDepot, select "openjdk17" in the "All packages" tab, and proceed with install :

Available demos

This package includes some demos located in the "/boot/system/lib/openjdk17/demo/jfc" folder :

To launch a few demos, packaged as java archives (the ".jar" files), type the below commands in a Terminal :

cd /boot/system/lib/openjdk17/demo/jfc/J2Ddemo

Then to execute the J2Ddemo archive :

java -jar ./J2Ddemo.jar

You can click on the various tabs available in this sample program to review all the features available regarding 2D graphics.

There's also another demo named "SwingSet2" available in the folder of the same name.

Type the below commands to launch it :

cd /boot/system/lib/openjdk17/demo/jfc/SwingSet2
java -jar ./SwingSet2.jar

You can discover the possibilities of the Java Swing API via this demo.

There's also a nice Stylepad demo editor available.

Launch it as below :

cd /boot/system/lib/openjdk17/demo/jfc/Stylepad
java -jar ./Stylepad.jar

Nice, isn't it ?

In case you need to access the Java sources corresponding to this demo, you can unzip the file named "src.zip" located in the same folder :

Demonstrations are fun, but now let's review real use cases.

Gaming usage

As indicated at the beginning of this article, Java brings a new ecosystem on Haiku. The first usage could be to run desktop games on Haiku. For instance there's FreeCol which is a turn-based strategy game based on the old game Colonization.

Download the java archive (".jar") available at the following location : https://github.com/FreeCol/freecol/releases

The interesting file there is the installer named "freecol-git-20241105-installer.jar".

Launch the installer with the below command :

java -jar freecol-git-20241105-installer.jar

Indicate in which folder you would like to install FreeCol :

Proceed with the installation until the last step :

Go into the folder where the game is installed and launch the game :

./freecol

You should see the below welcome screen, click on "New" to start a new game :

Indicate the name of the player and validate with "Ok" :

At the beginning, the aim is to find a land where the ship can come :

Once the land has been found, the settlers can discover the new land and start some buildings :

For more information you can check the FreeCol Documentation User Guide.

Nice isn't it ? Another game available is called "TripleA".

It's a turn based strategy game and board game engine, similar to Axis & Allies or Risk.

You can download the latest version on this location : https://github.com/triplea-game/triplea/releases

Then retrieve the file "triplea-game-headed.zip". Unzip it in the folder named "/boot/home/games/triplea" and launch the game from a Terminal :

cd /boot/home/games/triplea
java -jar ./bin/triplea-game-headed-2.5.22294.jar

You should see the welcome screen below where you can start a local game :

And you should see the nice world map below :

For more information, check the TripleA game website.

As you can see the game ecosystem can by interesting with Java.

Education usage

There are also educational applications. Let's have a quick look on "Robocode". Robocode is a programming game, where the goal is to develop a robot battle tank to battle against other tanks in Java. The robot battles are running in real-time and on-screen.

To install the game, first download the archive of the installer : https://github.com/robo-code/robocode/releases

Check for the file named "robocode-1.9.5.4-setup.jar".

Then launch the installer :

java -jar robocode-1.9.5.4-setup.jar

The installation will use by default the "/boot/home/robocode" folder :

To launch the game, enter in a terminal the below command :

./robocode.sh

The main screen will be displayed at the start :

You can select a list of robots and start the fight by clicking "Start Battle" button :

You should see the robots fighting in real time :

In case you are interested in this education game, you can check the wiki website: https://robowiki.net/wiki/Main_Page

Utility usage

Games or education can be fun, but what about applications ? Indeed you can use Java to have additional utility applications on Haiku. For instance, the Genealogy application named "Ancestris" is directly available via HaikuDepot.

It will install the corresponding dependency which is the OpenJDK Runtime Environment 11.

Once installed, you can launch it via the applications menu :

Another field of usage is the possibility to have SQL clients written in Java running on Haiku.

This part will be detailed in a dedicated article in the future. Really great, no ?

Moving forward

I hope this article gives you a quick overview of the possibilities of using Java under Haiku.

Even if Java is not the preferred language for this operating system, it can be a really good option in case you didn't find any native application on Haiku that fit your need.

For the developpers who would like to start developing in this language, you can also install the IDEA IntelliJ CE software or Apache NetBeans IDE.

Both IDEA IntelliJ Community Edition and Apache NetBeans are available for free and can be installed directly via HaikuDepot.

Any feedback you would like to share on Java for Haiku ?

Then put a comment below :)


Powered by Bludit - Hosted by Planet Hoster
© 2025 Haiku Insider