-1

I am working on my GUI application in Eclipse IDE. When I am trying to run it, the following error message is thrown:

Java Virtual Machine Launcher - Could not find the main class:org.cnstar.wiki.app.GreatPlaces.Program will exit.


Update: here is how my main method looks like:

public static void main(String[] args) {
        NativeInterface.open(); 

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    // loading the Splash Panel
                    SplashPanel panel = new SplashPanel();
                    SplashManager manager = new SplashManager(panel);
                    panel.setMessage("Initializing...");
                    manager.repaint();
                    for (int i = 0; i < 100; i++) {
                        panel.setProgress(i);
                        manager.repaint();
                    try {
                      Thread.sleep(100);
                        } 
                    catch (Exception e) {
                       }
                    }
                    manager.closeSplash();

                    start_application();

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        NativeInterface.runEventPump();
    }

And the methods connected to main method:

private static void start_application() {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
                    GreatPlaces window = new GreatPlaces(true, true);
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

public GreatPlaces(final boolean fullscreen, boolean showSplashScreen) {
        LocaleHandler.setLocale(); // will set the application language based to the local language of the machine

        initialize(fullscreen, showSplashScreen);

        setViewLayout();

        installAction();
    }

PROBLEM FOUND: I have just reinstalled my JRE, make clean to my project and it suddenly started to work! Thanks all for help!

4

2 回答 2

0

看起来您已经在内部类中定义了 main 方法。请参阅之前发布的这个问题:静态内部类中的主要方法。?

也就是说,如果你想把它放在一个内部类中,那么你需要这样定义主类:

org.cnstar.wiki.app.GreatPlaces$Program
于 2013-04-01T19:56:09.877 回答
0

检查 Eclipse 工作空间中的 .project 文件是否具有以下内容

<buildSpec>
    <buildCommand>
        <name>org.eclipse.jdt.core.javabuilder</name>
        <arguments>
        </arguments>
    </buildCommand>
</buildSpec>
<natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
</natures>

或者检查你在eclipse中编译的java类的输出文件夹是否正确

Java 构建路径 --> 源代码 --> 默认输出文件夹

于 2013-04-01T19:15:35.570 回答