Reputation: 9
In a application I made, I put my resources files to a folder(named YoutubeAudioAutoDownloader-resources
) and made sure it worked when i put the folder next to .jar file of my app.
And When I use jpackage
to make a exe installer with following cmd code: (sorry for dirty code because of my terrible directory arrangement, only part I want to stress is --type
and --resource-dir
options)
set jh=D:\development\jdk-14\bin
set appname=YoutubeAudioAutoDownloader v1.2.2
pushd %jh%
jpackage --type app-image --name "%appname%" --input "%~dp0packaging\jar" --dest "%~dp0packaging" --main-jar "YoutubeAudioAutoDownloader v1.2.2.jar" --main-class "com.awidesky.YoutubeClipboardAutoDownloader.Main" --resource-dir "%~dp0release.v1.2.1\YoutubeAudioAutoDownloader-resources" --icon "%~dp0icon\icon.ico
pause
I got question:
Where should I put my YoutubeAudioAutoDownloader-resources
folder? in app
folder of my app image folder? or I don't have to do because of --resource-dir
option? (I'm not sure whether I even know correctly about the option)
Upvotes: 0
Views: 1728
Reputation: 11
While this response may come a bit late for you, it may help somebody else.
If you would like to have your resources accessible to your packaged app you should be able to use --app-content path/to/resourcesFolder
this will then package that folder along with your App in a folder with the same name as your resourcesFolder. You can also see this here
If you want the packaged app to be able to access an existing folder on the users drive perhaps you can create an input field to get the path from the user and save the response in such resources folder.
Upvotes: 1
Reputation: 15196
The --resource-dir
parameter in jpackage is for changing the resources of the application EXE such as icons etc but it sounds like you actually want local resources accessed by your own classes with myClass.getClassLoader().getResourceAsStream("somerespath.xyz")
.
I don't think JDK14 jpackage gives a way to specify a local resources directory to add to the classpath of the running jpackage EXE. But it does add jars so if you bundle all of your resources directory into a jar along with a simple Java class say MyNewClass
you could locate the resources with:
MyNewClass.class.getClassLoader().getResourceAsStream("pathto/aresource.xyz");
This new jar would need to be with your other jars so it is picked up with --input "%~dp0packaging\jar"
and then the classpath field of each launcher EXEs app/xyz.cfg
should refer to the extra resources jar.
Upvotes: 1