This content has been marked as final. Show 6 replies
Thanks for the response. Could you please tell me how will specify my properties file in the following location to the jVM as classpath?
my app will be running from D:\RES_TEST.
will this be correct. Bu this did not work..
D:\RES_TEST> java -cp Properties -jar <executable-jar>
You're using the -jar option to run your jar as an executable jar? Then the -cp option does nothing. The classpath comes from the manifest in your jar file.
But in real life I would put the resource bundle in the jar file with the classes. Trying to distribute it separately and set up an entry in the manifest to include it in the jar's classpath would be way to much trouble.
JOBY1985 wrote:There are plenty of options. However all of them involve some design up front, which you haven't done yet. In my opinion the best option is this:
Thanks Paul once again, My intention was to make the properties file as a seperate one so that the use may change properties / messages without rebuilding the project. Anyways, if no other option is available, i have to stick to this....
You distribute the default version of the properties file in the jar file. Your code uses that version if nothing else is available. (You access that version via the classpath.)
If the user wants to customize the properties, then you save the modified version in the user's directory. Your code looks for that version first, and if it's not there then it uses the default version from the jar file. (That version is in a known location, so you access it from there.)
I don't understand what you mean by "rebuilding the project" there. This "project" is something in your development environment, isn't it? Surely you aren't expecting the user to install Netbeans or something like that just to run your application?
Thanks Paul. Finally I did it, using the normal procedure. I dont have a runnable jar now.. i give my jar file in the classpath + the properties file path. and then i give the class to run,
java -cp myjar.jar;PropertiesfilePath <MainClass>
Now it works fine,.
Thanks for your advice and time