JShell Java 학습을 위한 대화형 도구이며 REPL(Read-Evaluate-Print-Loop)입니다. 선언, 명령문 및 표현식을 평가합니다.
JShell 세션을 종료하는 동안 이전에 새 세션에 입력한 코드를 재사용하려고 합니다. 다음 명령을 사용하여 수행할 수 있습니다. /open [File_Path] . 이 명령은 file[File_Path]에 있는 모든 코드와 내부 명령을 로드합니다. 옵션으로 제공됩니다.
아래 코드 스니펫에서 다음을 사용할 수 있습니다. "/[파일_경로] 열기" ".jsh"가 있는 디렉토리에서 소스 코드를 로드하는 명령 확장자.
C:\Users\User>jshell
| Welcome to JShell -- Version 9.0.4
| For an introduction type: /help intro
jshell> x
| Error:
| cannot find symbol
| symbol: variable x
| x
| ^
jshell> y
| Error:
| cannot find symbol
| symbol: variable y
| y
| ^
jshell> /list
jshell> /open C:\Users\User\Desktop\save.jsh
jshell> /list
1 : int x = 15;
2 : double y = 25.0;
3 : public int sum(int a, int b) {
return a + b;
}
jshell> x
x ==> 15
jshell> y
y ==> 25.0
jshell> int result = sum(5, 7)
result ==> 12