7

I set up my project as described in the IntelliJ setup tutorial, but I am unable to start the Desktop application. The android app starts up fine in both the emulator and on my S3, but main in Desktop is unable to find my class..

Logs:

Exception in thread "main" java.lang.ClassNotFoundException: com.xxx.xxx.xxx.DesktopStarter
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)

I am running Mac OSX 10.7.5, Apple's Java JDK 1.6.0_43, and IntelliJ 12.0.4. I feel like it is something dead simple, I just can't seem to find the issue. (Don't laugh at my class name, it's for my 4yr old daughter) ;D

PANCAKES
  • 361
  • 1
  • 3
  • 11
  • I think it is a linking issue, but I can't seem to hunt it down. – PANCAKES Mar 14 '13 at 17:28
  • As expected, this was a simple issue. I needed to do a full rebuild of the project - the .class file was not generated in the project out/ directory. Silly IntelliJ – PANCAKES Mar 14 '13 at 18:22

2 Answers2

29

LibGDX 1.7.1, IntelliJ IDEA 15.0, Windows 8.1 -- I kept getting the problem trying to run DesktopLauncher through the IDE's Run Configurations dialogs.

Instead, running the Gradle task (desktop -> run) works perfectly.

To run the Gradle task within IntelliJ,

  1. Hit Shift twice, type "Gradle" to open the Gradle projects pane
  2. Hit the "Refresh all Gradle projects" button if nothing is showing up
  3. Expand :desktop > Tasks > other
  4. Double-click "run"
TalkLittle
  • 8,866
  • 6
  • 54
  • 51
  • 3
    funnily enough, the IntelliJ IDEA Run option now works after running the gradle build – Rots Oct 05 '16 at 07:46
  • This happens to my case only with kotlin, and selected with desktop option. I need to do above steps once, sync `build.gradle` after that normally run the project works properly. – haxpor Jul 05 '17 at 14:11
1

This is a bug with intellij. I have been informed it will be fixed soon.

For the meantime.

Click the gradle tab on the right side of the editor window.

Click the blue refresh icon.

Expand desktop -> tasks -> other Then double click on "run".

Dean Brown
  • 11
  • 1