How to run a JShell File?

前端 未结 7 985
借酒劲吻你
借酒劲吻你 2020-12-19 00:08

I\'d like to run an entire file with JShell like:

$ jshell my-jshell-skript.java

Where e.g. the content of my my-jshell-skript.java

7条回答
  •  太阳男子
    2020-12-19 00:29

    Launch jshell in concise feedback mode and filter the required content-

    $echo '40 + 2' | jshell --feedback concise | sed -n '2p' |sed -En 's/[^>]*>(.+)/\1/gp'
    

    output: 42

    More details here- How to execute java jshell command as inline from shell or windows commandLine

提交回复
热议问题