You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You always could to jbang --interactive <your.java|jsh|jar|gav> to have jbang start up your application/script within the jshell interpreter. Which is great but what if you just wanted to try out some API's without having to bother making a file to get started?
Now you can - just use jbang --interactive or jbang -i for short and you have a jshell. Of course that in itself is not interesting, but when you combine it with --deps it does become interesting. i.e. below is an example of starting jbang in interactive mode with access to h2 and jandex libraries.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Changelog
Small changes this time with a big impact.
-i
for interactive without sourcesYou always could to
jbang --interactive <your.java|jsh|jar|gav>
to havejbang
start up your application/script within the jshell interpreter. Which is great but what if you just wanted to try out some API's without having to bother making a file to get started?Now you can - just use
jbang --interactive
orjbang -i
for short and you have a jshell. Of course that in itself is not interesting, but when you combine it with--deps
it does become interesting. i.e. below is an example of starting jbang in interactive mode with access to h2 and jandex libraries.-c
for code snippet executionjbang
now can execute java code directly allowing you to process standard input to make great one-liners like:or this check for how many 5 letter words contains Man's best friend?
In the last example you will notice a few things:
-c
enables that the first argument is treated as code instead of a scriptSystem.in
println
top-level method is available to easily print.We got more ideas on adding some top-level methods to enable using java on
the command line.
And of course you can combine
-c
with--interactive
and--deps
and even-s myscripts.jsh
to load your own top-level methods.Enjoy and Stay tuned :)
🚀 Features
--code
option for running literal scripts (feat: Added--code
option for running literal scripts #1243)Contributors
We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, GitHub
This discussion was created from the release v0.90.0.
Beta Was this translation helpful? Give feedback.
All reactions