我发现了这个问题,而另一个,这个有趣的是它引出了几个问题,至少对我而言:
相当开放的问题,但在哪里被jshell 限制?显然,GUI应用程序不在域中用于jshell解决方案或IDE替换:
超出范围的是图形界面和调试器支持.JShell API旨在允许IDE和其他工具中的JShell功能,但jshell工具并非旨在成为IDE.
维恩图或其他视觉效果的奖励积分.
当然,片段的大小应该是有限的.我更想问一下使用片段无法解决哪些问题.
也可以看看:
我是Java的新手,但我正在阅读Java:How to program(第9版)这本书并且已经达到了一个例子,对于我的生活,我无法弄清楚问题是什么.
这是教科书中源代码示例的(略微)增强版本:
import java.util.Scanner;
public class Addition {
public static void main(String[] args) {
// creates a scanner to obtain input from a command window
Scanner input = new Scanner(System.in);
int number1; // first number to add
int number2; // second number to add
int sum; // sum of 1 & 2
System.out.print("Enter First Integer: "); // prompt
number1 = input.nextInt(); // reads first number inputted by user
System.out.print("Enter Second Integer: "); // prompt 2
number2 = input.nextInt(); …Run Code Online (Sandbox Code Playgroud) 我愿意将参数传递给jshell脚本.例如,我会喜欢这样的事情:
jshell myscript.jsh "some text"
Run Code Online (Sandbox Code Playgroud)
然后在脚本中的某个变量中提供字符串"some text".
但是,jshell只需要一个文件列表,因此答案是:
File 'some text' for 'jshell' is not found.
Run Code Online (Sandbox Code Playgroud)
有没有办法将参数正确传递给jshell脚本?
到目前为止,我唯一的解决方案是在调用脚本时使用环境变量:
ARG="some test" jshell myscript.jsh
Run Code Online (Sandbox Code Playgroud)
然后我可以在脚本中访问它:
System.getenv().get("ARG")
Run Code Online (Sandbox Code Playgroud)