问题
I have been developing a simple game using libgdx on my Windows 7 PC. Recently I bought a macbook pro (mountain lion). I downloaded and installed JRE 7 and eclipse, then cloned and imported the project. However though there are no errors in the code when I run the desktop version I the JVM loads and quickly dies. The error I get in the console is as follows:
JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
_NSJVMLoadLibrary: NSAddLibrary failed for /libjawt.dylib
JavaVM FATAL: lookup of function JAWT_GetAWT failed. Exit
AL lib: ReleaseALC: 1 device not closed
I've added JRE 7 to the build path libraries, still no joy.
The desktop launches through this code:
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
public class Main {
public static void main(String[] args) {
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "colourgame";
cfg.useGL20 = false;
cfg.width = 480;
cfg.height = 800;
new LwjglApplication(new ColourGame(), cfg);
}
}
Really stuck on this ladies and gents. Please get back to me! Thanks.
回答1:
According to this http://lwjgl.org/forum/index.php/topic,4711.0.html problem is with compatibility of JRE 7 update 6 with Lwjgl.
Problem seems to be fixed in a newer release of the library. I'm not sure if libgdx is updaetd accordingly but you can try to put the new version in your libs folder.
回答2:
This problem got sorted with the latest nightly build from libgdx, after doing this I got stucked into another problem, the method IntersectRectangles was missing in that release.. So i had to go back to the latest stable version and got that working, but... the problem mentioned above appeared again. So I´m going to stick to the latest stable version so I can deploy on my android device with the code working...
So temporal solution: to test while you develop use the nightly build, if you don't need the method above all should be fine(I wonder if there are more methods missing I didn´t have to use..)
回答3:
If you still need to use a stable or old release of libgdx. You might want to try to install jdk 1.6 (which I have done) in addition to jdk 1.7.
1. Download JDK1.6
Use this question to download jdk 1.6: jdk 6 on mountain lion
2. Add JRE home
In eclipse, go to preferences -> Java -> Installed JRE's and add jdk 1.6's home (just as your 1.7 version should be).
3. Set run configuration to use 1.6
Go to Run -> Run configurations -> YOUR CONFIGURATION -> JRE. Select 1.6 as the alternative JRE. :)
来源:https://stackoverflow.com/questions/13571726/cant-load-libgdx-desktop-app-on-mac-osx