如何编译没有
main
的java

解决方案 »

  1.   

    直接用javac编译就可以了,只有运行程序时才要求有main()。
      

  2.   

    象编译有main方法的类一样编译.也许你想要是如何让ide自动编译,呵呵.
      

  3.   

    没有main主方法就是Applet程序要用浏览器来调用
      

  4.   

    public class Test
    {
    static
    {
    System.out.println("There is only a static block ,rather than a main method");
    }
    }
     唯一的缺陷就是会抛出exception
      

  5.   

    噢,对了,加上System。exit()就不会有exception了
    public class Test
    {
    static
    {
    System.out.println("There is only a static block ,rather than a main method");
    System.exit(0);
    }
    }
      

  6.   

    用eclipse直接可以拿到class文件