天天看點

Java REPL & JShell

Java REPL & JShell

Java REPL

JShell

Java 11

Java REPL & JShell

Java REPL & JShell
Java Shell

The Java Shell or JShell is an official Read-Evaluate-Print-Loop, or REPL as it's commonly called, introduced with Java 9.

It provides an interactive shell for quickly prototyping, debugging, and learning Java and Java APIs, all without the need for a public static void main or the need to compile your code before executing it.

And as an added plus, using JShell just got a whole lot less verbose (and more practical) with the advent of the var keyword in Java 10!

Java REPL & JShell
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)

​​https://java-repl.xgqfrms.repl.run​​

​​https://repl.it/@xgqfrms/java-repl#HelloWorld.java​​

 javac -classpath .:/run_dir/junit-4.12.jar:target/dependency/* -d . HelloWorld.java Main.java

 java -classpath .:/run_dir/junit-4.12.jar:target/dependency/* Main

Hello world!

⚠️ 建立檔案 HelloWorld.java 的檔案名必須要與類名保持一緻

注:String args[] 與 String[] args 都可以執行,但推薦使用 String[] args,這樣可以避免歧義和誤讀。

​​https://www.runoob.com/java/java-tutorial.html​​

​​

Java REPL & JShell
釋出文章使用:隻允許注冊使用者才可以通路!

xgqfrms