[You need to download the JDK and configure the corresponding environment variables before performing the following operations]
1. Create a new text document file in any folder and write the following code
public class Hello{
public static void main (String[] args){
System.out.print("Hello,World!");
}
}
2. Modify the file name and file type to Hello.java
Special attention: the file name must be the same as the name of the class in the code!
PS:
Some computers may automatically set the hidden file suffix so that after changing the file name to Hello.java, the window shows that the file cannot be found, because the hidden suffix only modifies the file name, not the file type, and the following adjustments can be displayed File extension.
Just open a folder, click View - Options - View - Advanced Settings - uncheck "Hide extensions for known file types"
3. Compile the file
Hold down the shift key + right-click on the folder where the file is located to select "Open Powershell window in this book", enter
javac file name.java (example: javac Hello.java) automatically generates a class file
4. Run the file
Enter the java file name in the opened Powershell window to run the file (example: java Hello) and output the result