4

How to run java program in cmd

 3 years ago
source link: https://marco.dev/java-run-cmd
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.

Author

Marco Molteni

Marco Molteni Blog


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK