Searching for available install packages on Debian / Raspbian / Ubuntu (Installing Java on a Raspberry Pi Zero)

On Linux distros that use apt package manager, you can search for packages by name using:

sudo apt search package-name

I’m looking to install a supported version of OpenJDK on a Raspberry Pi Zero, which has significantly less resources than a regular Pi and I believe is also an older ARM cpu version than current Pi 4 and 5.

Using ‘apt search’ for openjdk shows a number of 7, 8, 11 and 17 candidates, and also versions compiled specifically for the Pi Zero:

openjdk-17-jre-zero/oldstable-security 17.0.11+9-1~deb11u1 arm64
Alternative JVM for OpenJDK, using Zero

Configuring Java version in a Maven based app

There’s a couple of different ways to configure the Java version for an app in your Maven pom.xml file.

The simplest is with the following properties:

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

If you’re configuring a Spring Boot app with Maven, you can also use this single property (only works for a Spring Boot app using the starter parent spring-boot-starter-parent) to override the Spring Boot default:

<properties>
<java.version>17</java.version>
</properties>

Skipping tests during Maven phases

If you’re running a Maven phase/goal and need to skip the execution of tests (because they’re temporarily failing), add one of the following options:

mvn -DskipTests phasename
mvn -Dmaven.test.skip=true phasename

Normally you’d only continue with the build if the tests are passing, but sometimes you may have a valid reason to force the build to continue regardless.

These options are covered in the Maven docs here.

Building a Maven based Spring Boot app with multiple app classes with main() methods

I have a Maven based Spring Boot project with 2 Application classes. One is my main Spring Boot app, the other is a standalone example app. When attempting to build with ‘mvn package’ I get this error:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.4:repackage (repackage) on project xample-client: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.6.4:repackage failed: Unable to find a single main class from the following candidates [kh.aprs.botexample.APRSISBotExampleApplication, kh.aprs.clientexample.APRSISClientExampleApplication]

The 2 apps listed are my 2 apps, but only APRSISBotExampleApplication is the one I want to get packaged, so I need to tell Maven which is the the main app. This is configured with the <start-class> property, configured in a properties section like this:

<properties>
 <start-class>your.package.YourApplication</start-class>
</properties>

This is described here.