Re:1JPM: A Maven/Gradle alternative in a single Java file
by grishka on Monday July 08, 2024 @10:08PM
(#40911893)
Sadly you can't, Java doesn't support comments starting with #
Self-executable jars though, that's an interesting idea. No reason why it can't work, zip archives are read from the end, you can put anything in the beginning, including "#!/usr/bin/java -jar"
[ Parent
| on HN ]
Re:1JPM: A Maven/Gradle alternative in a single Java file
by mbreese on Monday July 08, 2024 @10:55PM
(#40912115)
For the self executing JAR, I normally add a bash/shell stub for the header that ends with
java -jar $0
The rest of it sets up the environment (JAVA_OPTS, -Xmx, etc).
Re:1JPM: A Maven/Gradle alternative in a single Java file
by jnellis on Monday July 08, 2024 @10:24PM
(#40911966)
I believe you can use shebang since java 11 but you can't have the filename extension be .java.
Re:1JPM: A Maven/Gradle alternative in a single Java file
by grishka on Tuesday July 09, 2024 @12:06AM
(#40912453)
It turns out you indeed can: https://news.ycombinator.com/item?id=40912444