setSettingsDialogImage doesn't work when using executable jar

Hi there,

I might have an easy to solve problem. But, although searching for an answer on the internet, I haven’t been able to come up with any solution. So I’d appreciate any hint on this.

So, the problem is the following:
Below, I created a minimal example source-code to show what is causing me trouble. It is just a shortened version of what you get when you create a new SimpleApplication-project in jME3-SDK. I can run the program within the SDK - when I want to run it outside of the SDK, I simply clean and build it, double-click the created executable jar and everything works just as expected. Now, I want to change the dialog image on the startup-screen. So, the only change I applied to said source-code is, that I added the lines for changing the dialog image.
I can run the program within the SDK and everything works just the way I want (dialog image is changed and is shown). However, when I clean and build it, an executable does get created, but after double-clicking it, just nothing would happen. I mean nothing. When I add a splash-screen image in the project properties, that splash-screen would be shown upon starting the jar-file. After that, nothing again.
It all seems to come down to the mere changing of the dialog image. When I comment out the line of settings.setSettingsDialogImage(), the jar would work again.

Here is the minimal example code:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.system.AppSettings;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

public class Main extends SimpleApplication {

    public static void main(String[] args) {
        AppSettings settings = new AppSettings(true);
        settings.setResolution(640,480);
        settings.setSettingsDialogImage("Interface/image.png");
        
        Main app = new Main(); 
        app.setSettings(settings);
        app.start();
    }

    @Override
    public void simpleInitApp() {
        Box b = new Box(1, 1, 1);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);

        rootNode.attachChild(geom);
    }
}

Could anybody tell me whats going on there? What do I need to do in order to make the executable jar executable when applying a change to the dialog image?

I’d be happy about any help.
So, thanks in advance!

Two things you can try… first, try putting a / on the beggining:
settings.setSettingsDialogImage("/Interface/image.png");

If that doesn’t work then try moving the image into your src tree in some package and reference it there. Like in your example, put it next to Main.java and then reference it as:
settings.setSettingsDialogImage("/mygame/image.png");

I have a game I’m working on right now with the splash image working fine and that’s the way it’s setup. I don’t know which step is required, though.

Hi pspeed,

thanks a lot for your very quick reply.
I tried both of your suggestions. However, the result stays the same. The program works fine within the SDK. The executable wouldn’t do anything…
(Just to be exact: It’s not the Splash-Screen that is causing trouble but the dialog image. But I guess that is what you meant)

There is one error message coming up when building. Not sure if it has anything to do with my problem though:

warning: [options] bootstrap class path not set in conjunction with -source 1.5
1 warning

I don’t know man, this code works in my latest app:

        Main main = new Main();
        AppSettings settings = new AppSettings(true);
        settings.load("Ethereal Space - lite");
        settings.setTitle("Ethereal Space - lite");
        settings.setSettingsDialogImage("/espace/espace-lite-splash.png");
        settings.setUseJoysticks(true);
        
        main.setSettings(settings);        
        main.start();

…and is virtually the same code that I’ve used in every app.

If you’ve moved the image to your src tree then the only other thing to try is verifying that it is actually in your app’s jar. Otherwise, I’m not sure what the issue is because this worked in JME 3.0 and it works in 3.1.

Thanks again.

I copied your code into my project and ran it again (with a different PNG-file name of course). Same result as usual… I don’t get it.
This time the only difference is that my problem applies to the settings.load()-line, too. So, now I had to comment out both settings.setSettingsDialogImage()and settings.load() in order to get the jar running…

I did try moving the image to src. How can I verify that my jar actually contains the image file?

Go to the “Files” tab in the explorer and unfold the jar file in dist.

Hi Normen,

ok, I used File → Open File → dist/MyGame.jar
The image is indeed included. Just next to Main.java since I put it in src earlier.

Anything else I could try?

Can you show us your latest code?

Sure. Didn’t change anything really though:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.system.AppSettings;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import java.util.prefs.BackingStoreException;

public class Main extends SimpleApplication {

    public static void main(String[] args) throws BackingStoreException {
        Main main = new Main();
        AppSettings settings = new AppSettings(true);
        //settings.load("Ethereal Space - lite");
        settings.setTitle("Ethereal Space - lite");
        settings.setSettingsDialogImage("/mygame/image.png");
        settings.setUseJoysticks(true);
        
        main.setSettings(settings);        
        main.start();
    }

    @Override
    public void simpleInitApp() {
        Box b = new Box(1, 1, 1);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);

        rootNode.attachChild(geom);
    }
}

And can you list the contents of your game’s jar?

According to the SDK-explorer that is:

                   MyGame.jar
                       |
META_INF (package)     -     mygame (package)
        |                           |
   MANIFEST.MF           Main.class - image.PNG

Hope my humble drawing is comprehensible :wink:

Do you not see the difference between the name of the file and the file as referenced in your code?

Look really closely.

Remember class resources are case sensitive.

Whoa, I do. Wasn’t aware of the fact that class resources are case sensitive. And never came up with the simple idea to change it since it worked within the SDK… Anyway that was the point, it’s working now.

Well, embarrassing.

Thanks a lot for your help :smile:

I do not know if it is true or not, but I suspect that JME itself is super case-sensitive to maintain the OS compatibility. It is almost impossible to design a game on Windows that refuses to run in Linux since JME enforces these case sensitivities. Just a side note… :slight_smile:

Interesting in any way.
I just find it somewhat odd that it would allow me to program without caring too much about the cases then. Why not throw a compiler error at me in the first place?

The compiler can’t know about what assets will be there at runtime or not, so it can’t just put out an error on a string. When you run the project in the SDK the assets are loaded from a folder so it depends on your OS/filesystem if its case sensitive or not. Later when the app is deployed the assets are loaded from a jar file which is always case sensitive.

Hi Normen,

awesome, thanks a lot for the explanation.
That’s really good to know :smile: