Post
Quick start guide for Java Development on Haiku
Haiku is an open source operating system inspired by BeOS. This guide focuses on getting started with 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 still in a beta phase, Haiku is surprisingly fast and responsive. 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 and exploring how the ecosystem of Java software builds and works on it. Therefore I am writing this small guide with the steps to get started with Java development on Haiku. This guide focuses on the most basic thing for a developer: installing the tools for building and testing your software.
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. At this moment, the featured packages show only a build for the, now ancient, Java 8. Search for openjdk on the depot to find additional 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 it from the project website at https://maven.apache.org. It's 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.
Extracting the file using the command line interface (CLI)
Extracting the file via CLI is not different than 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, but the file location is slightly different. To add to the path, 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.
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 use 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>