简体   繁体   English

错误:找不到或加载ALGenerator

[英]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. 我启动了一个新的LibGDX项目,并收到此错误。 I thought that maybe it was just because I was trying to avoid gradle. 我以为也许只是因为我在尝试避免gradle。 So I made a new project using gdx-setup.jar. 因此,我使用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? 仅仅是因为我现在正在使用LibGDX 1.1.0吗? So I ran a previous LibGDX project which was just working. 因此,我运行了一个之前正在运行的LibGDX项目。 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. 因此,我认为现在与Eclipse有关,但不确定。 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. 我的搜索结果始终小于10。因此,我猜没有其他人会收到此错误。

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. 删除的项目,通过gdx-setup.jar重新创建...相同的错误。

The problem is that you do not have the correct class as the startup class. 问题是您没有正确的类作为启动类。

To fix, do the following in eclipse. 要解决此问题,请在eclipse中执行以下操作。

In the Package Explorer, Right Click the project you are having issues with. 在Package Explorer中,右键单击您遇到问题的项目。 The go to properties and to Run/Debug Settings. 转到属性和“运行/调试设置”。 This will have your launch class. 这将有您的启动课程。 For me is said ALGenerator. 对我来说,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. 单击搜索,然后找到其中包含“ public static void main(String [] args){}”的类。 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. 程序包资源管理器> ProjectName(右键单击)>属性>运行/调试设置>选择类,例如。 ALGenerator > Edit > Main (tab) > Main class: > Search > Then do as instructed above ALGenerator>编辑>主(选项卡)>主类:>搜索>然后按照上面的说明进行操作

Pictures to assist: 图片协助:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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