Language selector

script

In the past I wrote two posts about Java sripts and their portability using shebang. As far as I can tell everything in these two installments is still valid, only now, in Java 21, thanks to JEP-445 things can be even simpler. In this post I’ll try to describe fist the changes introduced by this JEP, then go deeper on how they relate to the “scripts in Java”. I’m going to cover how you can simplify your main method, get rid of the class surrounding it, and even show you when it won’t work.
The shebang hasn’t been discussed deeply in the previous post. Let’s find out how can we squeeze this fruit in our beloved JavaScript(s). Is it possible to write the shebang in a way which makes it portable?
Some people find it shocking, that it’s possible these days to write a script (which will run in CLI) not only in Bash, Perl, Python or PHP, but also in Java.

Language selector