Is there a way to run short bits of Java code without compiling?

后端 未结 9 1421
無奈伤痛
無奈伤痛 2020-12-25 15:33

Is there a way to run or simulate running Java statements (kind of like IDLE - the Python GUI) without compiling and running the executable? I want to quickly test statement

9条回答
  •  一个人的身影
    2020-12-25 16:14

    As of Java 11 (JEP 330) it is now possible to run Java files directly with the java tool:

    java Factorial.java 3 4 5
    
    is informally equivalent to
    
    javac -d  Factorial.java
    java -cp  Factorial 3 4 5
    

    Java also added support for "shebang" files.

    For more details see: http://openjdk.java.net/jeps/330

提交回复
热议问题