Forums Register Login

Is there a best practice for packaging external text files with a Java app?

+Pie Number of slices to send: Send
I have my project setup with the following directories



The .class files obviously go in the jar file. The images directory contains images used by the GUI, again, into the jar file. The data directory contains information used by the methods in the java app, again into the jar file. The scripts directory contains files not used by the Java app directly. I start another program and then pass a command to that program ('source scripts/myscript') which defines a function in that program, I can then send commands to run the function I created.

I originally was not using a jar file, so I could just source the scripts files. It seems I have two options when using a jar file:

1. Put all the files in the jar file, then when I run, copy out the scripts files to a tmp directory and source them from there

2. Leave the scripts directory out of the jar file and define an environment variable so that I can find them.

I'm leaning toward (1), the scripts files only total about 40K.

Would anyone have comments about the advantages and disadvantages of one method over the other? Or a better approach in general?

Thanks.
+Pie Number of slices to send: Send
My approach is to have everything that goes together stay together. If the scripts don't get used directly by anything in the jar file, they don't go together. For easier distribution, I would put everything in a zip or tar.gz file, with the contents structured so that when everything is extracted, they go in the right place and the end user would simply need to read the included README file and/or run a setup script or something like that to get going.
You know it is dark times when the trees riot. I think this tiny ad is their leader:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 608 times.
Similar Threads
NX: Packaging of Submissions
Jar files...dont know what is the problem
deploying packages
problems in executing a jar file
Listing files in a JAR??
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:59:25.