首先在notepad.exe新建一个文件Test.java,代码如下:
public class Test{ public static void main(String[] args){ System.out.println("Hello Java"); } }
打开cmd,切换到Test.java目录: 编译java代码:
javac Test.java
运行java程序:
java Test
注意,类名要与文件名相同,否则会出错:“找不到或无法加载主类”