1. First, use Notepad to write a simple Java program and save it as a .Java file
2. Search on the computer Search cmd in the text box or directly use the keyboard menu key r to open the command window
3. Enter the cd file location in the window that appears. If I put it on the desktop, enter cd Desktop and press Press Enter. If you enter dir Desktop and press Enter, the files on the desktop will be displayed (ps: you don’t need to do this, you can also enter it directly after the file name of the Java file)
4. Enter javac a.java after the address where you store the Java file. a is the initial name. javac means compiling this Java file. Press Enter and a new file will appear where you store the Java file
5. Then enter Java again and press Enter to complete the Java program. It runs and successfully outputs helloworld
Recommended tutorial:Java tutorial
The above is the detailed content of How to run java in cmd. For more information, please follow other related articles on the PHP Chinese website!