Categories
Coding Haiku Java

Java Development on Haiku

Haiku is an open source operating system inspired by BeOS, an operating system developed by Be Inc in the 90s. Although it’s still in a beta phase, Haiku is surprisingly fast and responsible. You can find many reviews on the web about it.

During the last few days I have been playing with it on a virtual machine on my Intel NUC. The environment for Java development is not prepared out of the box, therefore I am writing this small guide with the steps to setup a Java development environment on Haiku. This guide focuses on the most basic thing for a developer: installing the tools for building, testing and writing your your software.

Haiku desktop

Installing a JDK

You can use the application HaikuDepot to install a JDK. There are packages for Java 8 to 14. It seems there’s no package for Java 17 yet, however. At this moment, the featured packages display a build for the Java 8. Unless you need that ancient version skip it, instead search for opendjdk on the depot to find additional packages.

Haiku depot showing available OpenJDK packages

Alternatively, you can also install the package command line. Open the terminal (you can find it on the application list on the Menu on the top right) and type: 

pkgman install openjdk11_default

SDKMAN! does not support Haiku, so you’ll have to manually install the usual tooling for Java development. I’ll describe the steps I took to install Apache Maven. You can probably follow the same steps to install other tools.

Download the latest version from the project website. The file is going to be saved on the ~/Desktop directory. At this time, Maven 3.8.6 is the latest version, therefore the downloaded file on my system is: ~/Desktop/apache-maven.3-8.6-bin.tar.gz.

Extracting the file using the Expander

You can double click the package on your desktop to use the Expander utility to extract the file. Choose /boot/home/tools as the destination directory. 

Haiku Expander utility

Extracting the file using the command line interface (CLI)

Extracting the file via CLI is similar to what you would do on Linux, *BSDs or MacOS. You can use the following command:

mkdir -p ~/tools ; tar -xvf ~/Desktop/apache-maven.3-8.6-bin.tar.gz  -C ~/tools 

Tip: just like on Linux, you can use the command readlink -f ~/Desktop/apache-maven.3-8.6-bin.tar.gz to resolve the full directory of the downloaded file – that would be /boot/home/Desktop/apache-maven.3-8.6-bin.tar.gz in this case. 

Setting up Maven

If you had extracted the file via UI, then open the terminal.

Switch your directory to ~/tools and create a symbolic link to the extracted Apache Maven directory. 

ln -s apache-maven-3.8.6 apache-maven

You’ll probably notice that if you invoke Maven via CLI, it won’t work. That’s because the scripts that launch Maven are not on the path. 

You can do so by adding it to the PATH variable. This customization is similar to what is done on Linux, *BSDs and MacOS, however the file location is slightly different. To add to the patch, edit the ~/config/settings/profile file.

Note 1: Haiku comes with Nano installed by default. If you prefer Vim, it can be found on the HaikuDepot. 

You can add the following contents to the file:

#Common path to install the tools you need for Java development
export TOOLS_HOME=$HOME/tools

# Point the M2_HOME variable to the Maven installation directory
export M2_HOME=$TOOLS_HOME/apache-maven

# Append each too to the PATH variable, so it can be found when using the CLI
export PATH=$PATH:$M2_HOME/bin

Save the file and exit the shell using the exit command.

Open a new shell window and type: mvn --version. It should print the Maven version.

Maven running on Haiku using the terminal

Now you should be ready to try building your project.

Note: some projects may enforce OS restrictions on the build (i.e.: using maven plugins and so on – please don’t you this kind of thing unless you have a very serious reason for it). For example, to disable the OS check on the os-maven-plugin, you can use mvn -DfailOnUnknownOS=false <target>

Maven building a package on Haiku

IntelliJ IDEA

Then, at last, you can install an IDE, so you can write and change the code. Haiku comes with a package for IntelliJ IDEA. The package is a bit old, but it should not prevent you from writing code and enjoying most the features of this awesome IDE.

IntelliJ IDEA running on Haiku

This looks cool! What should I know before playing more with it?

Well, first and foremost: it’s beta software, so it’s subject to a few bugs here and there. Hardware support may also be limited and can be problematic if you have exotic hardware.

Here’s some of the problems I encountered building a large project. They may or may not be related to Haiku because I ran it on a virtual machine (VM) on a host running Fedora 36 and I did not diagnose the root cause of any of them:

  • Transient name resolution problems transferring artifacts from my local maven repository
  • Memory pressure seems to cause the system to become unresponsive (this is just a guess – I did not diagnose the problem)
  • Git seems very slow and pulling with rebase a large repository causes the system to hang.
  • The builtin terminal in IntelliJ does not work.

I want to highlight that, by no means, this is detrimental to the system – it’s a beta after all and I never investigated the root cause.

Final Thoughts

Haiku is a fun OS to play with. Although there were some hiccups here and there, this is to me part of the fun of playing with unstable/beta software.

I was particularly impressed about how fast and responsive it was. It was fast even though I was using it on a virtual machine and accessing using VNC.

Now I am considering buying a cheap SSD so I can install it on my desktop, have a better feel of how it works on actual hardware and not have to worry so much with disk space.

Haiku disk space utilities

By Otavio Piske

Just another nerd

3 replies on “Java Development on Haiku”

Oh my goodness. I once bought beos it was after the bebop and ran it on a separate partition. The most amazing operating system. When Be went out of business I followed openbeos which became Haikus and was led by Michael Phipps. Then there was a company called Zeta that got hold of the beta for beos which they called zetaos. I bought that but it failed. I might give this a try. Thank you.

So Beos was out at the time the time of windows 98 and Apple classic. It have a fully preemptive kernel and an indexed filesystem. Apple still had cooperative multi tasking. I remember a demo where a guy was listening to an mp3, ripping a DVD, encoding the Stream and the watching the encoded video without band lags. Completely impossible on anything else. Apple made an offer to buy BE for hundreds of millions of dollars before Steve Jobs came back. They rejected the offer and then there was the DOT bomb where tech stocks crashed. BE sold to palm who made it the core of their new handhelds for a few million. Then Palm folded and Palm got bought by LG I think. A very sad end to what was a truly revolutionary OS and miles ahead Next which Steve jobs brought to Apple.

I ran BeOS back in 1990s. It was fun. When Palm acquired it, Palm had a worthy OS on its hand that could have even morphed into a phone OS. But for whatever reason, Palm decided against it and let it die.

Leave a Reply

Your email address will not be published. Required fields are marked *