Assets/data was not found on deploy?

When I run from jme, everything is ok. If I do a clean & build, then run the resulting .jar I get this error:

java.lang.Error: the folder assets/data was not found.

I’ve checked, and assets.jar contains the assets/data folders and files. So I don’t understand what’s wrong :frowning:

assets/ only exists in the SDK because the project is run with the project folder as root which contains the folder assets/, when you deploy the app the folder is compressed into a jar file which is added to the project classpath. So you’ll have to fetch your file from the classpath (no File()) and without the assets/ prefix.

InputStream in = this.getClass().getResourceAsStream(“data/SomeTextFile.txt”);

1 Like

Which will work both ways…

Basically, if you are using File() then you do it wrong.

1 Like

Wow… this means that OpenRTS is broken outside the IDE… GoldMonkey will fix that! :smile:

InputStream in = this.getClass().getResourceAsStream(fileName);

Returns null, even though fileName is present (minus the assets/ prefix). I have to say that I’m calling it from a library and not from my game, like this:

/src (the call happens here)

mygame.jar (includes goldmonkey.jar)
/src/ invokes the goldmonkey appstate
/assets/ the file I’m looking for

Try adding a slash at the beginning

1 Like