Created
January 18, 2022 05:41
-
-
Save FrancescoJo/4149dcd0f4b696e22ae84a97e11b7a9a to your computer and use it in GitHub Desktop.
Run jshell as script engine
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/env jshell --show-version "$0" "$@"; exit $? | |
public class Runner { | |
public static void main(final String[] args) { | |
System.out.println("Runner#main"); | |
} | |
} | |
System.out.println("Executing class"); | |
Runner.main(new String[0]); | |
final int code = 5; | |
/exit code |
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
> jshell example.jsh | |
Executing class | |
Runner#main | |
> echo %ERRORLEVEL% | |
5 | |
> |
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
$ ./example.jsh && echo $? | |
Executing class | |
Runner#main | |
5 | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment