Skip to content

Instantly share code, notes, and snippets.

@andirady
Last active September 17, 2021 23:43
Show Gist options
  • Save andirady/be9088908459503f0363eaca4d670f74 to your computer and use it in GitHub Desktop.
Save andirady/be9088908459503f0363eaca4d670f74 to your computer and use it in GitHub Desktop.
Run Java as a script. Requires Java > 9
///usr/bin/env java $0 $@; exit
public class hello {
public static void main(String[] args) {
System.out.println("I'm a script! Or am I? 😉");
}
}
/* to run it, execute a follows:
$ ./hello.java
*/
@andirady
Copy link
Author

Apparently, you don't have to make it executable. This may lead to security issues. 🤔

@andirady
Copy link
Author

Updated to simpler header. Inspired by jbang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment