简体   繁体   English

当我没有要执行的文件时如何运行 jshell?

[英]How to run jshell when I don't have a file to execute?

I would like to run jshell like this我想像这样运行jshell

$ jshell --execute 'System.out.println("Hello World")'
Hello World
$

So it executes the java single code line and terminates.因此它执行 java 单代码行并终止。 Is it possible?可能吗?

You can use a pipe:您可以使用 pipe:

echo 'System.out.println("Hello World")' | jshell -

From jshell --help :jshell --help

A load-file may also be "-" to indicate standard input, without interactive I/O.加载文件也可以用“-”表示标准输入,没有交互式 I/O。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM