1.首先安装java环境 http://www.cnblogs.com/ldybyz/p/6261714.html
2.在路径D:myprojectjavafirstjava(可自己定义) 新建一个MyfirstApp.java文件
3.添加如下代码,注意类名MyfirstApp必须和文件名一致,而且一个文件中公共类(public)只能有一个
public class MyfirstApp { public static void main(String[] args) { System.out.println("Hello World!"); } }
4.打开cmd命令窗口,切换到java文件所在路径,并输入javac和java命令
输入命令:D:
输入命令:cd D:myprojectjavafirstjava
输入命令:javac MyfirstApp.java
输入命令:java MyfirstApp
可看到窗口输出 Hello World!
C:Userslindy>d: D:>cd D:myprojectjavafirstjava D:myprojectjavafirstjava>javac MyfirstApp.java D:myprojectjavafirstjava>java MyfirstApp Hello World!