Open plinto
Docs›Languages

Java

Language·4 min read
In one sentence

JavaBuild compiles your Java with the JDK your group pins, tests it with JUnit and builds a jar. Naming a main class makes it a program.

Build systemJavaBuild
Start oneplinto create java-service HelloApp (or java-lib)
Ships asan archive with its own JDK

The project

HelloApp/
  plinto.conf
  src/             your code: src/helloapp/Main.java
  resources/       files that go into the jar as they are
  tst/             tests
  tst-resources/   files the tests read
  configuration/   JavaBuild.config, the build's settings (optional)
plinto.conf
{
  name = HelloApp
  version = 1.0
  build = JavaBuild
  main = helloapp.Main         # what `plinto run` starts

  build-dependencies: {
    JavaBuild = 1.0
    Java = 25
  }
  dependencies: {
    Slf4jApi = 2.0.17           # imported from Maven Central
  }
  test-dependencies: {
    JUnitJupiter = 6
  }
}

Java = 25 is the JDK, Amazon Corretto, at the release your version group points 25 at. Kotlin files belong in a Kotlin project: JavaBuild refuses them.

A program

A project that names its main, the class with the main method, is a program: plinto run starts it, and its release can be packaged to run on a server. Without one it is a library. Nothing is guessed from the code.

$ plinto run -- world

What follows -- goes to main, after the arguments args = [--port, 8080] in plinto.conf names, which the packaged program starts with too. The JVM's own options go in the settings, as run.jvm-args.

Settings

Settings go in configuration/JavaBuild.config, one key = value per line, or in plinto.conf as java: { release = 21 }. A key set in both places is an error, and so is a key JavaBuild doesn't know.

Key What it does
java.release the Java version to compile for (default: the JDK's own, such as 25)
java.compiler-args more arguments for javac
run.jvm-args what plinto run passes to the JVM: [-Xmx512m]
configuration/JavaBuild.config
java.release = 21

Libraries

Libraries from Maven Central come in through an import, once per group, and then each project names them by their package name:

$ plinto import maven org.slf4j:slf4j-api:2.0.17
dependencies: {
  Slf4jApi = 2.0.17
}

Tests

Put JUnit tests in tst/ and JUnitJupiter in test-dependencies. plinto build runs them and prints the tree of what passed.

What it releases

A reproducible jar, build/libs/HelloApp-1.0.jar. A program is also packed as an archive, HelloApp-1.0-<platform>.tar.gz, with the jar, its libraries and its own JDK, started by HelloApp/bin/HelloApp. A scripts/run.sh in the project replaces how it starts. See Deployments.

Native binaries with GraalVM are coming.