How to run a simple Java program using terminal command

command linejavaterminal

Image1

As you can see I'm trying to run a Java program but I need the command which I can write in terminal to run the code.

Best Answer

I imagine the easiest way would be to press the blue arrow at the top.

If it has to be command line though, try

Javac Main.java

To compile the source to byte code which will give you a Main.class file, then

Java Main

To run it. The oracle website has a quick guide here

Related Question