Last active
September 19, 2023 10:21
-
-
Save ffissore/012d7e32a096fde5266f49038c93dcaf to your computer and use it in GitHub Desktop.
with jshell-wrapper you get runnable java scripts: it removes the heading shebang, adds an "/exit" for good measure, and passes the result to jshell
This file contains hidden or 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
TMP=`mktemp` | |
tail -n +2 $@ >> $TMP | |
echo "/exit" >> $TMP | |
$JAVA_HOME/bin/jshell -q --execution local $TMP | |
rm $TMP | |
#put this file in /usr/local/bin/ or somewhere in your $PATH |
This file contains hidden or 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
federico@pawa:~$ JAVA_HOME=/opt/jvm/jdk1.9.0/ ./test.sh | |
Hello world! | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 |
This file contains hidden or 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/env jshell-wrapper | |
System.out.println("Hello world!"); | |
IntStream.range(1, 10).forEach(System.out::println); | |
Great wrapper! I've made some changes to load lib and use in a Nginx as GCI.
I put in this project: https://github.com/deividgermano/jshell-cgi-wrapper
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great wrapper script, but I changed the following line so I dont need the environment variable:
$JAVA_HOME/bin/jshell -q --execution local $TMP
to:
/usr/bin/env jshell -q --execution local $TMP