Java¶
Enterprise-grade object-oriented programming
Overview¶
Java is a widely-used, object-oriented programming language known for its 'write once, run anywhere' philosophy. With run, you can compile and execute Java code without managing complex project structures.
Basic Usage¶
Hello World¶
run java "public class Main { public static void main(String[] args) { System.out.println(\"Hello, World!\"); } }"
# Output: Hello, World!
Multi-line Code: Use Heredoc
For multi-line code, use heredoc (<< 'EOF') to avoid shell quoting and escaping issues.
REPL Behavior¶
Java's REPL maintains state across commands. Variables, classes, and methods persist within the same REPL session.