比如你的代码(Greetings.java)存放在:D:\testJDK,在cmd窗口中cd D:\testJDK 输入javac Greetings.java(回车) (如果没有任何提示则编译通过) 在输入java Greetings(回车)