public class helloworld {

   public static void main(string[] args) {

       system.out.println("hello world!");

    }

}

首先编译,进入E盘,输入“e:”然后enter

接着输入 Javac helloworld.java

 

就是这个5行的小程序,出现了3个错误

1:错误:类helloworld是公共的,应在名为 helloworld.java 的文件中声明 public class helloworld {

2:错误:找不到符号 public static viod main  <string[] args>{

符号:类 string

位置:类 helloworld

3:错误:程序包system不存在

system.out,println<"hello world">;

百度后初步解决错误2和3,2修正需要把string的“s”大写,3修正需要把system的“s”大写(看来还是要怀着虔诚畏惧的心,注意大小写==)

再次百度,发现错误1,也是由于不够虔诚,恩,书里有说明文件名一定要是helloworld.java .

以为只要文件名是.java结尾的就行,类:helloworld 是公共的,文件名需与类名相同。将文件名改为helloworld.java,ok啦~

成功将.java的源代码文件编译成程序可识别的.class文件。

由于是green,遇到了不知怎么用DOS 打开E盘,就是输入“E:”然后按enter键就可以了。

 posted on 2018-08-28 15:47  庭明  阅读(169)  评论(0编辑  收藏  举报