How to compile and run in single command in java

Sachin Muthumala :

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
kadar :

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=136054&siteId=1