I have developed Java desktop application using Netbeans. In my application, I used some properties files and I placed it under the Project folder so that I can access it by using code like that
Properties props = new Properties();
props.load(new FileInputStream("config.properties"));
But when I deploy and package my application to .jar file, I can't find out where properties files are and my application can not read value from properties files.
How can I fix that bug, and where should I place my properties file and load it?
Put it under /src/resources/
, then use it like below.
ResourceBundle props = ResourceBundle.getBundle("resources.config");
NetBeans doesn't include the files under your project directory. Further, you need to build the project, in order to let NetBeans put the properties
file inside your /classes
directory. Then you should be able to pick it up, by running your application or just a particular related Java class.
Cheers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With