File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Properties File from Jar

 
Sam Codean
Ranch Hand
Posts: 194
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading all the strings for my assignment from a Properties file and also am storing the user selected preferences from this file.

Now in case the current working directory does not contain the suncertify.properties file then i have to create a new one with the defaults read from the jar file. Please can someone help me solve this?
How do i read from the file that is present in my currently executing jar. Or should i hard code the string values in an interface?
 
Mike Ngo
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading all the strings for my assignment from a Properties file and also am storing the user selected preferences from this file.


"all the strings for my assignment" means the strings for your application?
If that is the case, follow the common convention and put them in a bundle.

The default user settings should be part of the class that read/write properties file.
 
Sam Codean
Ranch Hand
Posts: 194
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes all the strings for my application.
please can you elaborate on what you just said?
I have two sets of data, all the strings of the ui
and the preferences of the user. I store all of it in the suncertify.properties file. I do use a ResourceBundle to read the Strings but my question still remains how do i read it? if the file is not present then i cannot use any strings and hence i have to go to default for sTrings. I have not hard coded any string in any of my classes but i hard code the default values of data file , port number, UI Strings etc in the code and if the props file is present then overwrite it?
 
Mike Ngo
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can store the application strings in a resource file. The resource file is jar'ed along with the application classes in the runme.jar so the application can always find it.

|_ ApplicationResources.properties
|_ suncertify.db



The application can be run from any dir so if the suncertify.properties file cannot be found you can use the applicatin default. If it is present, you can overwrite the application default.
 
Sam Codean
Ranch Hand
Posts: 194
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike. I was confused how will the application read from a file that is bundled in a jar. You made me life easy.
Thanks a ton
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic