Okay this might be a lot of text, but I guess the more means the better you guys can help me.
So I was making a game (no surprise), in Slick. I really wanted 3D, but didn’t really want to spend all that time in OpenGL. I heard about jMonkey and I checked it out and it was just what I needed. Now before I explain what the actual problem is, I better tell you how the launcher for my game works. When you start the launcher it creates a JFrame and adds an applet to it (when running in browser it starts with the applet), then it updates the game, after that it launches the game by adding it as an applet. The game and all its code is located in a separate jar. I got this working with Slick, but I can’t get it to work with JMonkey. When I open up the jar for my test jMonkey game it works no problem, and when I it as an applet in Netbeans it also works no problem. When I run it through the launcher I get this error:
[java]Dec 02, 2011 6:52:21 AM com.jme3.system.Natives getExtractionDir
WARNING: Working directory is not writable. Using home directory instead.
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at com.jme3.system.Natives.computeNativesHash(Natives.java:86)
at com.jme3.system.Natives.getExtractionDir(Natives.java:69)
at com.jme3.system.Natives.extractNativeLibs(Natives.java:202)
at com.jme3.system.JmeSystem.initialize(JmeSystem.java:349)
at com.jme3.system.JmeSystem.newContext(JmeSystem.java:270)
at com.jme3.app.Application.createCanvas(Application.java:394)
at net.battlecruiserwars.GameApplet.init(GameApplet.java:38)[/java]
Just in case you are wondering what my GameApplet class looks like here it is.
After trying to get to work, which those attempts failed, I downloaded the jMonkey source and made this change to the first few lines of computeNativesHash()
[java]
private static int computeNativesHash() {
try {
// String classpath = System.getProperty(“java.class.path”);
// URL url = Thread.currentThread().getContextClassLoader().getResource(“com/jme3/system/Natives.class”);
String sep = File.separator;
URL url = new URL(System.getProperty(“user.home”) + sep + “Desktop” + sep + “Battlecruiser Wars” + sep + “lib” + sep + “jMonkeyEngine3.jar” + sep + “com” + sep + “jme3” + sep + “system” + sep);
String classpath = System.getProperty(“user.home”) + sep + “Desktop” + sep + “Battlecruiser Wars” + sep + “lib” + sep + “jMonkeyEngine3.jar” + sep + “com” + sep + “jme3” + sep + “system” + sep;[/java]
So that fixed that problem, but of course another arose:
[java]Dec 02, 2011 7:03:48 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.IllegalStateException: No loader registered for type “fnt”
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java
:274)
at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:
400)
at com.jme3.app.SimpleApplication.loadFPSText(SimpleApplication.java:183
)[/java]
I did some digging around and found out that:
public DesktopAssetManager(URL configFile)
is called the and configFile is null when using my launcher, but when you run the game jar directly it isn’t. I could try to fix, but I feel like I’m going down the wrong path.
oO what the heck are you doing there? ^^ You have to use the applet harness when creating applets, check the applet deployment option in the SDK.
Do you have to?
I want to do something similar to the way minecraft and its launcher works. I wasn’t sure if jMonkey could be this modular or not. I guess not, but since i got it to work with LWJGL and Slick without too much fuss, I feel like it could work with jMonkey.
Yes you have to, jME3 needs a binary and they can only be in applets when they are signed. Its a bit more complicated than a normal Applet.
hmm okay…
Well I’m going to give one more try cause I really want to make this work. I didn’t post it because I had to go, but I did change around the DesktopAssetManager(URL) constructor and got it to work. Then I had AssetNotFound (or something like that) exceptions which I think I can fix. If I do get it I’ll be sure to post.
Just check the checkbox under “Applet”.
Yes, that works, but when you launch the game through my launcher it doesn’t which is the problem.
Got it to work :), I had to extract some of the resouces from the jMonkeyEngine3.jar: the Desktop.cfg, and everything in the Common and Interface folders to the working directory and change the first line in Desktop.cfg to use FileLocator.
Thanks for trying to help, It probably was pretty confusing
You have no working directory for applets… oO
The launcher, after done updating the game files, opens and runs the game jar that is saved somewhere on your computer in a game file folder. The game jar then sets the “user.dir” property to where the game folder is. I guess that’s how I can get around the no working directory that way.
Ah, so its the root directory of your applet effectively.
If you have full permissions while running as an applet then you can just run jME3 as a standard desktop application that has an AWT canvas. This would work better than a jME3 applet which is designed to work with LWJGL’s AppletLoader