First: open the console cmd.exe, then enter: java -version
Then enter: javac
Recommended related learning video tutorials: java course
The above information appears to prove that the Java environment is configured correctly.
Then find the java file path from the command line.
For example, mine is placed under F:\javaTest\src\zz, and the file name is Test.java
To compile the Java file, the command is : javac file name
A file with the suffix .class appears under the folder
Finally enter the command : java file name (the file name cannot have a suffix)
# An error was reported because there is a package name in it.
Remove the package name, recompile and run.
Finish!
Recommended related articles and tutorials: zero basic introduction to java
The above is the detailed content of How to compile and run java files in the console. For more information, please follow other related articles on the PHP Chinese website!