can't find main class问题(原理未知)

can't find main class

在网上搜了下,说是JDK与eclipse版本问题,我将jdk的版本从1.5改为1.6,果然问题解决了。我使用的是eclipse3.5.

 

具体原理是什么还不清楚,估计是classloader那里的问题,以后需要再研究下

can not find the main class问题.

12-24

这个问题我还是第一次碰到,首先声明的是,我的编译基本和运行的jre都是1.6的.eclipse也进行Project->clean.rngoogle上很多都说是jre的问题,说指向run configuration中的 classpath 中的 user entities,advance,add folders,然后指向bin目录.rn是么,但是都不行.rn我甚至删除eclipse的 .metadata然后重新导入项目,还有替换项目下的 .classpath,都不行.rn我在同一个包下运行普通的类很正常,但是运行一个继承ImageIcon,实现Runnable的类后,就是这样.rn会不会是 swing的问题?我的代码如下:rn[code=java]package spt.proxy;rnrnimport javax.swing.ImageIcon;rnimport javax.swing.JFrame;rnrnpublic class ImageIconProxy extends ImageIcon implements Runnable rnrn public static Object obj = ImageIconProxy.class.getClassLoader().getResource("img/absent.png");rn public static final ImageIcon ABSENT = new ImageIcon(rn ImageIconProxy.class.getClassLoader().getResource("img/absent.png"));rn static final ImageIcon LOADING = new ImageIcon(rn ClassLoader.getSystemResource("image/loading.png"));rnrn ImageIcon current = ABSENT;rn protected String fileName = null;rn protected JFrame callbackFrame = null;rnrn public ImageIconProxy(String fileName) rn// super(ABSENT.getImage());rn System.out.println("absent:" + ABSENT);rn this.fileName = fileName;rn rnrn public void load(JFrame callbackFrame) rn this.callbackFrame = callbackFrame;rn current = LOADING;rnrn callbackFrame.repaint();rn new Thread(this).start();rn rnrn @Overridern public void run() rn current = new ImageIcon(ClassLoader.getSystemResource(fileName));rn callbackFrame.pack();rn rnrn public int getIconWidth() rn return current.getIconWidth();rn rn rn public int getIconHeight() rn return current.getIconHeight();rn rn rn public void show() rn callbackFrame.setVisible(true);rn rnrn rn public static void main(String[] args) rn System.out.println("absent:" );rn rnrn[/code] 论坛

没有更多推荐了,返回首页