Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java How do I read and write an internal properties file?

I have a file I'm using to hold system information that my program needs on execution. The program will read from it and write to it periodically. How do I do this? Among other problems, I'm having trouble with paths

Example

enter image description here

How do I read/write to this properites file if deploying application as runnable jar

like image 919
stackoverflow Avatar asked Jun 28 '26 00:06

stackoverflow


1 Answers

Take a look at the http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html

You can utilize this class to use your key=value pairs in the property/config file

Second part of your question, how to build a runnable jar. I'd do that with maven, take a look at this :

How can I create an executable JAR with dependencies using Maven?

and this :

http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

I see you're not using maven to build your project altogether

like image 52
ant Avatar answered Jun 29 '26 13:06

ant