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
but no luck.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With