Home >Java >Javagetting Started >How to compile and run java program in terminal on mac system

How to compile and run java program in terminal on mac system

王林
王林Original
2019-12-09 16:27:086734browse

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.

How to compile and run java program in terminal on mac system

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

How to compile and run java program in terminal on mac system

Then enter "javac Hello.java" to compile the source program

How to compile and run java program in terminal on mac system

After the compilation is completed, a .class file will be output

How to compile and run java program in terminal on mac system

Finally enter "java Hello" in the terminal to run the program

How to compile and run java program in terminal on mac system

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn