<- Back

How to run java program in cmd

prepare and compile

You have to create a java class that contains a main method:

public static void main(String[] args)

You need to compile your class to execute it:

javac YourMainClass.java

This command generates a YourMainClass.class file that can be executed.

run the java class

java YourMainClass

The Java Runtime should be installed and accessible from your terminal.

<- Back