Missing asset files after build game

I have a problem when i try to run my gamer after building it cause it cant fiind a File from the assets directory

in JME all works fine
the clean-build process shows no error and i don’t know why this error appears when i run the jar file mit ‘java -jar myGame.jar’

java.io.FileNotFoundException: assets/Files/settings (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at java.io.FileReader.<init>(FileReader.java:58)
    at utiles.FileHandler.readAllSettingsFromFile(FileHandler.java:54)
    at utiles.FileHandler.<init>(FileHandler.java:40)
    at myGame.initFileHandler(myGame.java:34)
    at myGame.<init>(myGame.java:30)
    at myGame.main(myGame.java:86)
Exception in thread "main" java.lang.NullPointerException
    at settings.Settings.loadSettings(Settings.java:45)
    at settings.Settings.<init>(Settings.java:39)
    at utiles.FileHandler.<init>(FileHandler.java:42)
    at myGame.initFileHandler(myGame.java:34)
    at myGame.<init>(myGame.java:30)
    at myGame.main(myGame.java:86)

i know what this error means, it cant read my settings file
but if i look in the dist directory i have the asset.jar in the libs directory

any idea? i guess there is something wrong in the build properties

Is your lib folder in the same directory as your MyGame.jar?

Is your assets.jar inside your lib folder?

as i said the assets.jar is in the lib folder

the dist directory looks like

  • MaGame.jar
  • MyGame-windows.exe
  • lib
    |— assets.jar
    |— …

This file has no extension so it’s probably being excluded from the build. Check your build’s settings and see what extensions are excluded from being packed in the jar.

As always it would be helpful to see the actual usercode (utiles.FileHandler) doing things.
From here it looks like you try to access the Path assets/Files/settings which is the Path inside of the IDE and works like this, but after release there is no assets Folder and it isn’t available via a FileInputStream either.

You need to see how the AssetManager loads Files. You don’t even use the assets.jar right now

in the settings are this exclues (i didn’t changed there atm)


but i dont see a exclude there for files with no extension
also if i look in the asset.jar the ‘settings’ file is still there

i load the file with
BufferedReader settingsReader = new BufferedReader(new FileReader("assets/Files/settings"));

Well, there’s your problem. That directory doesn’t exist when you deploy.

If you want a settings file on disk then you will have to manage that yourself. Assets are bundled into a jar and can either be loaded by the asset manager or as class resources.

1 Like

now i understand the problem :slight_smile: thanks

any idea for a good way to save / load settings?

Use cache directories for every OS on which you want to release your game. You have to register the directory for each different OS (Example,AppData for windows) and the file separator,but this shouldn’t be so difficult.

ok thanks
i will try this out

Actually, depending on what settings you want to store you can simply use the AppSettings object to store your settings.

currently some key settings and video / audio stuff like resolution or volume

as i understand the appsettings correctly, i can save there only video settings but not key or audio volume

You can put whatever you want in it… it’s just a Map.

hm next time i should look into the javadoc first

i only took a look on the documentaion of the appsettings

i guess the AppSettigns would fix my problem

thanks for the very fast help :slight_smile: