Syntax

Java Compile and Run Syntax

In Java, compile and run: compiles and runs a Java file from the terminal — javac Main.java java Main

Quick Answer

Syntax
javac Main.java java Main
JavaSyntax

Compile and Run

Code example
javac Main.java java Main

Compiles and runs a Java file from the terminal.

Learn More

How to compile and run in Java

  1. Open your Java file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Java Compile and Run Syntax

Use javac Main.java java Main.

Related Syntax References

Frequently asked questions

What is the Java syntax for compile and run?

Use this pattern: javac Main.java java Main

Can I copy this Java code example?

Yes. Use Copy code and adapt the example to your program.

Is this Java syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify