Last active
March 27, 2024 13:17
An example of a Java program that can be executed as a shell script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/java --source 17 | |
public class EchoArguments { | |
public static void main(String[] args) { | |
System.out.printf("Arguments: %s%n", String.join(", ", args)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This ability has existed since Java 11, although this script utilises some Java 17 features as well.
Three requisites:
chmod u+x java-shell-script
.java
extension. (This caught me out for some time).