Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

jar files and properties files or file IO

  Asked By: Joel    Date: Feb 23    Category: Java    Views: 1119
  

My java application loads some properties files in a sub-folder
(using ResourceBundle), as well as reading some other files in that
folder using FileInputStream. When I put my class files along with
the sub-folder into a jar file, when running the jar file it can no
longer find these files in the sub-folder. How do I get this to work?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Vikram Aditya     Answered On: Dec 10

Jar file contains only "src" folder, so create a file called "resource" and keep the properties file.

Code to read data from properties file.

Properties logProperties=new Properties();
logProperties.load(ClassLoader.getSystemResourceAsStream("FILE_NAME"));
String logTableName = logProperties.getProperty("PROPERTY_NAME");


All the best

 
Didn't find what you were looking for? Find more on jar files and properties files or file IO Or get search suggestion and latest updates.




Tagged: