Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libgdx - Intellij class not found exception?

I am using intellij for the first time and I haven't been able to run any program. It builds without any errors or warnings but when I run, It throws the class not found exception. I have tried everything I could

  • Search on stack-overflow.
  • I've checked the source folder under the module setup.
  • I've checked the run configurations as well

but no luck.

Error:

Exception in thread "main" java.lang.ClassNotFoundException: com.nectarmicrosystems.libgdx.learning.desktop.DesktopLauncher
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)

the class source:

package com.nectarmicrosystems.libgdx.learning.desktop;

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.nectarmicrosystems.libgdx.learning.MyGdxGame;

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

dependencies

source structure

like image 680
conversation.16 Avatar asked Dec 07 '15 14:12

conversation.16


1 Answers

Thanks to every one that helped, I found the solution. basically the DesktopLauncher class was not getting compiled, so I ran the task through gradle this way:

look for the Gradle panel in the IDE, open desktop -> Tasks -> other and then double click on run.

you only need to do this the first time.

like image 191
conversation.16 Avatar answered Oct 04 '22 04:10

conversation.16