爱问知识人 爱问教育 医院库

运行JAVA The selection does not contain a main ty

首页

运行JAVA The selection does not contain a main ty

运行JAVA The selection does not contain a main typ运行JAVA The selection does not contain a main type用Eclipse 新建一个工程后,在工程下建了一个Example 类

package examplepack;                      /*用户自定义包*/
import  .*;                            /*类库装载*/

interface DealInt{                           /*声明一个接口*/
public abstract void dealInt();
}                                            /*接口声明结束*/
                                             
class ANumber implements DealInt{            /*声明一个类,实现接口*/
   int i=4;
   public void dealInt()                     /*实现接口中的方法*/
   {
      intln(i);
   }
}                                            /*类ANumber结束*/
                                             
public class Example {                       /*声明一个主类*/
  public static void main(String[] args)   /*主类的main方法*/
    {
       ANumber n1=new ANumber();
        alInt();                         /*调用方法*/
       n1.i=123;
        intln("n1.i="+n1.i);
       try{
          rrentThread().sleep(5*1000);
       }catch(InterruptedException e){}
  }                                        /*main方法结束*/
}                                            /*类Example结束*/



为什么运行时会"The selection does not contain a main type."代码是没有错误的啊.

提交回答
好评回答
  • 2008-05-17 14:28:07
    出现这个问题,是因为.java文件不在项目的src路径内,也就是说源代码未被eclipse编译,字节码不存在无法运行了 
    在项目名上右键 -> Builder Path -> Configure Build Path -> 选择Source面板,再点Add Folder, 把源代码所在的包路径的上层目录加进来.

    1***

    2008-05-17 14:28:07

类似问题

换一换

相关推荐

正在加载...
最新资料 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 178-197
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):