adam bien's blog

Java 25 Script Files with Classpath in the Shebang 📎

Java 25 script files (JEP 512: Compact Source Files and Instance Main Methods and JEP 458: Launch Multi-File Source-Code Programs) are self contained, but can specify a classpath in the shebang.

The Log.user, for example, is located in zcl.jar and can referenced with the following shebang:


#!/usr/bin/java --class-path=zcl.jar  --source 25
void main() {
  Log.user("Hello, duke");
}