How to compile and run in single command in java

情到浓时终转凉″ 提交于 2020-03-22 10:48:30

问题


I want to compile and run in the single command line. Usually, we first compile and after the run?

javac example.java

java example

can I run this,

javac example.java && java example

回答1:


You can use a function :

Myfunction() { javac $1.java && java $1 ; }

The use :

Myfunction example

This question is duplicated , please to search before posting See : Compile and build with single command line Java (Linux)

Regards




回答2:


Since Java 11 you can use a single command

java example.java

https://openjdk.java.net/jeps/330



来源:https://stackoverflow.com/questions/57180304/how-to-compile-and-run-in-single-command-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!