Write java code with Notepad

First of all, using Notepad to write java code requires configuring IDE and environment variables. The same goes for writing other types of code. Only java code is written here.

ps: I recommend using the Sublime Text notepad, but you can also use the notepad++ that comes with the computer.

1. Change the file extension

First, in the folder where you store the code, create a new text document named HelloWorld, and then change the .txt suffix to .java, it will become as follows.

2. Write HelloWorld in Notepad 

public class HelloWorld {

	public static void main(String[] args) {
		System.out.println("HelloWorld");
	}
}

3.win+r to open the command run box, enter cmd, and open the Windows console command window  

4. Enter the path where the .java file is located 

Use cd c: to enter the path to drive c, if your code is stored in drive d, use cd d:, and so on for other drives.

Then find the path where the .java file is located 

  

You can also directly enter cmd in the directory where the .java file is stored, and directly enter the directory where the .java file is located 

5. Use the javac filename.java command to generate a bytecode file 

What the computer can recognize is binary data, and the javac filename.java is actually the process of compiling. After compilation, the source file becomes a bytecode file (class) that can be recognized by the computer, and the bytecode is composed of a series of binary.

  

6. Use the java file name command to run the bytecode file and let the program run 

 The place marked in red is the identity of the bytecode file.

To add something, the command mentioned above, javac is used to compile, java is used to run, so where does the program run? Run on JVM (java virtual machine). 

The above is the simple operation of writing java programs with Notepad, I hope it can help you. 

Guess you like

Origin blog.csdn.net/m0_63562631/article/details/131988534