dotfiles
bugabingas dorkfiles
owned by admin
pi/agent/skills/optional/java/java-source-scripts/examples/jep-512.md
RawRendered preview
Source: https://openjdk.org/jeps/512
Compact source file with instance main:
void main() {
IO.println("Hello, World!");
}
Small script with imports and helpers:
import java.nio.file.*;
void main(String[] args) throws Exception {
Path file = Path.of(args[0]);
IO.println(Files.readString(file));
}
JEP 458 still applies to multi-file source programs: invoke the entry file only.
java Prog.java arg1 arg2
# [JEP 512](https://openjdk.org/jeps/512) examples
Source: https://openjdk.org/jeps/512
Compact source file with instance `main`:
```java
void main() {
IO.println("Hello, World!");
}
```
Small script with imports and helpers:
```java
import java.nio.file.*;
void main(String[] args) throws Exception {
Path file = Path.of(args[0]);
IO.println(Files.readString(file));
}
```
[JEP 458](https://openjdk.org/jeps/458) still applies to multi-file source programs: invoke the entry file only.
```bash
java Prog.java arg1 arg2
```