Skip to content

Elide for Java users

Switching from a JDK with Maven or Gradle to Elide: running Java source directly with JDK 25, what changes in builds and tests, benchmarks and trade-offs.

Read offlineelide help elide-for-java

On this page

Elide bundles JDK 25 with a build tool, Maven dependency resolver, JUnit runner and formatter in one binary.

Run the same code

A source file with a main method compiles and runs directly:

Terminal
bash
elide run Main.java

elide java, elide javac, elide jar and elide javadoc run the JDK 25 tools without a JDK install. Their arguments go after --:

Terminal
bash
elide javac -- -d out Main.java
elide java -- -cp out Main
elide jar -- --create --file app.jar -C out .
elide java -- -version

The distribution’s bin/ holds java, javac, jar, javadoc and javap, so an existing build can use it as JAVA_HOME; see JVM Toolchain.

A project is an elide.pkl file, which also lists Maven dependencies:

pkl
amends "elide:project.pkl"

jvm { main = "com.example.Hello" }

dependencies {
  maven {
    packages { "com.google.guava:guava:33.4.8-jre" }
  }
}
utf-8 · pkl · Lines: 9
Terminal
bash
elide init --plain --skip-defaults --template java   # new project
elide install                                        # resolve Maven dependencies
elide build                                          # compile and assemble
elide test                                           # run JUnit tests
elide run                                            # run jvm.main
elide format -- src                                  # Google Java Format

JUnit is on the test classpath without a declared dependency. See Java and Kotlin with Elide, Testing and the elide.pkl reference.

What changes

With a JDK, Maven or Gradle With Elide
Install a JDK Nothing; JDK 25 is bundled.
javac -d out Main.java elide javac -- -d out Main.java
java Main.java elide run Main.java
pom.xml, build.gradle elide.pkl
Resolve dependencies elide install; elide install -p . reads a pom.xml.
mvn package, gradle build elide build
mvn test, gradle test elide test
gradle run, mvn exec:java elide run
Maven goals on an existing pom.xml mvn package with the Maven plugin.
Migrate ./gradlew or mvn builds elide adopt; see Adopt an Existing Project.
native-image elide native-image -- -cp app.jar com.example.Main
google-java-format elide format
IDE project import elide project export --format=intellij or --format=pom

Benchmarks

No benchmarks are published for JVM programs in 1.6.0. For ahead-of-time builds, see Native Image.

Strengths

  • One binary replaces the JDK, Maven resolver, JUnit launcher and Google Java Format.
  • elide.pkl declares dependencies, tests and artifacts without plugins.
  • Annotation processors run in elide build and elide javac from a processors bucket.

Weaknesses

  • No Gradle support: elide build does not read build.gradle or build.gradle.kts, and Gradle plugins have no equivalent.
  • elide install -p . does not merge POM parents or imported BOMs; versions inherited from a parent are dropped.
  • No jlink, jpackage or jshell command, and JavaFX is not included.
  • elide adopt is untested on multi-module and Android projects.
  • javac jtreg tests: 99.9% pass (1 fail, 2 errors); see the Compatibility Matrix.
  • JDK tool arguments go after --: elide javac -d out Main.java exits 2.
  • Not sandboxed: Java programs currently run on HotSpot, which the sandbox does not cover. --sandbox and the --allow-* and --deny-* flags do not restrict them.

Next steps

Was this page helpful?