Java Compiler

Compile Java 25 source with elide javac or in a project build.

Compile source files

elide javac -- -d out src/Hello.java
elide java -- -cp out Hello
Compiling and running Java source with Elide

javac options go after --. Without -d, class files are written beside their sources. elide javac -- -help lists every javac option.

Elide options

Elide options go before --:

OptionPurpose
--jar PATHPack the output into a JAR at PATH.
--manifest FILEManifest for the --jar output.
--max-errors NErrors shown before the rest are counted; 0 shows all. Warnings are de-duplicated and never limited.
--report-used-deps PATHWrite the classpath entries the output references (Bazel strict deps).
--capabilitiesPrint compiler capabilities as JSON.
--persistent_workerRun as a Bazel persistent worker, singleplex or multiplex.
--classpath-cacheWorker only: reuse classpath state across compiles. ELIDE_WORKER_CLASSPATH_CACHE=0 turns it off.
elide javac --jar target/app.jar -- src/Main.java src/Util.java
elide javac --jar target/app.jar --manifest src/MANIFEST.MF -- src/Main.java

Build projects

elide build compiles src/main/java and src/test/java, or the source sets the manifest declares. To run only main Java compilation:

elide build compile-java-main
jvm {
  target = 25
  java {
    release = 25
    compiler {
      mode = "embedded"
      flags { "-Xlint:all" }
    }
  }
  features {
    graalvm = false
  }
}
PropertyMeaningDefault
jvm.targetBytecode target; the --release level when java.release is unset."auto" (21)
jvm.java.release--release level: compile against that JDK’s API only."auto"
jvm.java.sourceUse --source/--target instead of --release; ignored when release is set."auto"
jvm.java.compiler.mode"embedded" uses Elide’s javac; "external" runs the one in jvm.javaHome."embedded"
jvm.java.compiler.flagsExtra javac flags; --release, -source or -target here replaces Elide’s.none
jvm.javaHomeJava home for external compiles and forked JVMs.Elide’s own
jvm.debugCompile with -g.true
jvm.features.graalvmPut org.graalvm.nativeimage, word and collections on the compile classpath.false
jvm.features.automodulesPut JARs without a module descriptor on the module path as automatic modules.true

The --release level is java.release, else jvm.target, else 21. Each compile writes its arguments to javac.args beside its output. Annotation processors: Maven Dependencies.