Question

I tried to export a runnable Jar, but it did not execute. The problem was could not find main method for given launch configuration However I did specify the Main class in the launch configuration. i even renamed the class that contained the main method into Main for this purpose

enter image description here

I have specified the Main class that contains the main method, however, still the jar file did not run?


my Main class

public class Main {


        static Preferences userPreferences = Preferences.userRoot();
        final static String LOGIN_KEY = "login_key";
        .....................

        public static void main(String [] args) {
            Runnable r = new Runnable() {
                public void run() {
                    try {
                        createGUI();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }


            } ;

            javax.swing.SwingUtilities.invokeLater(r);

        }

    public static  void createGUI() throws IOException {

        JFrame j = new JFrame("C Manager");
        j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ActionListener al = new ActionListener() {
            @SuppressWarnings("deprecation")
            public void actionPerformed (ActionEvent e ) {
        ......................

    }



}
Was it helpful?

Solution

You may need to validate the name of your project in .project file, which is the project description file.

Here's a link: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html

Here's a typical .project file:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
        <name>MyProject</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
                <buildCommand>
                        <name>org.eclipse.jdt.core.javabuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>
</projectDescription>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top