Home >Java >Javagetting Started >How to compile and run java program in terminal on mac system
This tutorial is based on the fact that everyone has installed the JDK environment.
First write a simple program that outputs "Hello world".
Note that the program name must be saved with the .java suffix.
Then switch to the directory where the source program is saved in the terminal. Here I saved it on the desktop, so I switched to the desktop folder
Related video tutorial sharing: java course
Then enter "javac Hello.java" to compile the source program
After the compilation is completed, a .class file will be output
Finally enter "java Hello" in the terminal to run the program
Recommended related article tutorials: java entry program
The above is the detailed content of How to compile and run java program in terminal on mac system. For more information, please follow other related articles on the PHP Chinese website!