Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile and run in single command in java

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
like image 284
Sachin Muthumala Avatar asked Dec 03 '25 09:12

Sachin Muthumala


1 Answers

Since Java 11 you can use a single command

java example.java

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

like image 73
Miguel Ángel Júlvez Avatar answered Dec 05 '25 00:12

Miguel Ángel Júlvez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!