没有main方法,无法运行.要运行这个类,先要有main方法才行

解决方案 »

  1.   

    类路径的问题。 即使类里有 main 也一样报告这个错误
      

  2.   

    我在那里看到了已生成的class了。
    下面是我的程序:
    public class Ishmael
    {public static void main(String[] args)
     {String s="Call me Ishmael.";
       System.out.println(s);
       System.out.println("The length of the string is"+s.length());
       System.out.println("the first charaster of the string is"+s.charAt(0));
       System.out.println("The last charaster of the string is"+s.charAt(s.length()-1));
       System.out.println("The first word of the string is"+s.substring(0,s.indexOf(' ')));
    }
    }我是用windows系统运行的。
      

  3.   

    导入类的问题?
    import java.lang.*;
      

  4.   

    仍然是classpath问题!
    你需要设置classpath!
    如:classpath=.;c:\jsdk1.4.2\jre\lib\rt.jar
    设置好后记得关闭dos窗口重新开一个!运行时:java -classpath %classpath% Ishmael