[Java] Realize "HelloWorld" output with Notepad

[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

e8db28167ac8479fb3a56243bbc9b734.png

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!

b6189c497c914e95985b2bcdb5d41b23.png

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"

39ff39b7ab034b65a1f954b869eeadd6.png

07a9c975ef4c4cc2bd4dd0ce38dd5c3d.png

 

 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

691e56b9d1d444a0808c9e63b805bc41.png

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

 92ac5884d75446559d979c55ac954b06.png

 

 

Guess you like

Origin blog.csdn.net/m0_59800431/article/details/129072947