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
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
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.
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.