Reputation: 27592
I'm developing a Java Application in Netbeans. The application uses a .properties file (Properties
class). The problem is that Netbeans insert this properties file into final .jar file.
Upvotes: 2
Views: 4459
Reputation: 67
when you export project by jar formart from Eclipse IDE, you can config it do not import file .properties into jar file.
If you want use .properties file in the same folder with file jar, you can get current path with code:
String path = <NameClass>.class.getProtectionDomain().getCodeSource().getLocation().getPath();
and now, you can load file .properties from above path.
Good luck to you!
Upvotes: 1
Reputation: 308763
Look at the source directories that NetBeans is asked to insert into the JAR and remove the .properties
from the list.
You can always read the .properties
file by reading it as an InputStream
, as long as it's in the CLASSPATH
.
The question is: Why do you feel the need to move it out of that JAR? At least it's in the CLASSPATH that way. You seem to be acting against your own best interests here.
Upvotes: 1