libgdx - Intellij 類未找到異常? (libgdx - Intellij class not found exception?)


問題描述

libgdx ‑ Intellij 類未找到異常? (libgdx ‑ Intellij class not found exception?)

我是第一次使用 intellij,但我無法運行任何程序。它構建時沒有任何錯誤或警告,但是當我運行時,它會拋出 class not found 異常。我已經盡我所能

  • 在 stack‑overflow 上搜索。
  • 我已經檢查了模塊設置下的源文件夾。
  • 我'我也檢查了運行配置

但沒有運氣。

錯誤:

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)

類源:

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);
    }
}

依賴項

參考解法

方法 1:

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.

方法 2:

For people who are experiencing this problem, try selecting "desktop_main" in the "Use classpath of module:" drop‑down list.

I was getting this error when I selected "desktop" as the module but the error went away when I selected "desktop_main."

(by conversation.16conversation.16disperse)

參考文件

  1. libgdx ‑ Intellij class not found exception? (CC BY‑SA 2.5/3.0/4.0)

#libgdx #java #intellij-idea






相關問題

為什麼原生 libmpg123 在帶有 libgdx 的 android 上花費這麼長時間? (Why is native libmpg123 taking so long on android with libgdx?)

睡眠後重新加載應用程序 (Re-load the app after sleep)

獲取實際觸摸位置 LibGDX (Get actual touch position LibGDX)

LibGDX - 只有可拖動的運動 (LibGDX - only draggable movement)

無法解析符號“android” - 在使用 libgdx 在 Android 應用程序中實現 Google Analytics 時 (Cannot resolve symbol 'android' - While implementing Google Analytics in Android App with libgdx)

如何從矩形數組中刪除隨機矩形? (How to remove random rectangle from rectangle array?)

球在傾斜平面上滾動 java libgdx (Ball rolling on an incline plane java libgdx)

libgdx - Intellij 類未找到異常? (libgdx - Intellij class not found exception?)

GL_COLOR_BUFFER_BIT 再生哪個內存? (GL_COLOR_BUFFER_BIT regenerating which memory?)

libGDX - 更改屏幕後的黑色按鈕和文本 (libGDX - Black buttons and text after changing screen)

帶有 9patch 的 LibGdx 標籤背景 (LibGdx label background with 9patch)

如何從平鋪中刪除對象? (How do I remove an object from tiled?)







留言討論