Skip to content

Instantly share code, notes, and snippets.

@FrancescoJo
Created January 18, 2022 05:41
Show Gist options
  • Save FrancescoJo/4149dcd0f4b696e22ae84a97e11b7a9a to your computer and use it in GitHub Desktop.
Save FrancescoJo/4149dcd0f4b696e22ae84a97e11b7a9a to your computer and use it in GitHub Desktop.
Run jshell as script engine
//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
> jshell example.jsh
Executing class
Runner#main
> echo %ERRORLEVEL%
5
>
$ ./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