简体   繁体   中英

Error: Could not find or load ALGenerator

Error: Could not find or load main class com.badlogic.jglfw.generators.ALGenerator

I started a new LibGDX project and got this error. I thought that maybe it was just because I was trying to avoid gradle. So I made a new project using gdx-setup.jar. Then I went to run the desktop version and got the same error as above. So I was like, ok. Is it just because I am using LibGDX 1.1.0 now? So I ran a previous LibGDX project which was just working. I got this error again.

Well, time to try something different. I delete all the code in the desktop class and went from this:

package com.gdx.main.desktop;

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.gdx.main.GdxGame;

public class DesktopLauncher {
    public static void main (String[] arg) {
        LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
        new LwjglApplication(new GdxGame(), config);
    }
}

To this:

package com.gdx.main.desktop;

public class DesktopLauncher {
    public static void main (String[] arg) {
        System.out.println("Hello World!");
    }
}

I still got the same error. So I assume it is something to do with Eclipse now, but not sure. I googled the error, but couldn't find anything. My search results were always less than 10. So I guess no one else is getting this error.

Any ideas on where to start or have you encountered something similar?

EDIT

Did not change anything. Same error for new project, but now the old project is working fine. Weird...

Deleted project, re-created though gdx-setup.jar... same error.

The problem is that you do not have the correct class as the startup class.

To fix, do the following in eclipse.

In the Package Explorer, Right Click the project you are having issues with. The go to properties and to Run/Debug Settings. This will have your launch class. For me is said ALGenerator. I selected this and clicked edit. Under the Main tab is a field called "Main class:" which has a search button next to it. Click search and find your class that has your "public static void main(String[] args) {}" in it. This is the class you need to select. Select your main class and click apply. Then click ok. NOW YOUR DONE!

Package Explorer > ProjectName (Right Click) > Properties > Run/Debug Setttings > Select Class, Eg. ALGenerator > Edit > Main (tab) > Main class: > Search > Then do as instructed above

Pictures to assist:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM