After creating a new LibGdx project using the setup.jar file. I have followed the instructions for configuring my new application using IntelliJ and launching the desktop application. But I'm getting the following error:
Exception in thread "main" java.lang.ClassNotFoundException: com.mygdx.game.desktop.DesktopLauncher
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
DesktopLauncher.java:
package com.mygdx.game.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.mygdx.game.MyGdxGame;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new MyGdxGame(), config);
}
}
The IDE is saying "unused imports" suggested it can't find them at all.
Update:
11:54:56 Gradle 'newgame' project refresh failed:
Cause: org.gradle.plugins.ide.internal.IdeDependenciesExtractor.extractRepoFileDependencies(Lorg/gradle/api/artifacts/ConfigurationContainer;Ljava/util/Collection;Ljava/util/Collection;ZZ)Ljava/util/List;
This fixed it for me:
On the Desktop "Run/Debug" configuration, select the appropriate JRE directory. For me, it was: C:\Program Files\Java\jre1.8.0_73.
Had the same problem with freshly-generated gdx project. Solved by adding desktop:build task to run before launch.
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