Daniele Milani Daniele Milani - 1 year ago 102
Java Question

Add properties file to build path of runnable jar

is it possible to add to the classpath of a runnable jar file some properties file?
I tryed these solutions solutions:

  1. running the executable file using the following command:

    java -cp ../prop_dir/prop1.properties;../prop_dir/prop2.properties -jar MyRunnableJar.jar

  2. adding to the MANIFEST FILE (in the Class-Path section)

    ../prop_dir/prop1.properties ../prop_dir/prop1.properties

but none of them works.

The architecture of the running dir is the following

+ MyRunnableJar.jar
+ prop_dir/
+ prop1.properties
+ prop2.properties

Thanks so much,



When I execute the following line


I obtain in my console


Answer Source

In order to solve this problem i used a workaround: instead of running the runnable jar i runned the main class and I added the jar to the classpath.

The command I used is the following one:

java -classpath .;MyRunnableJar.jar;prop_dir; my.package.MyClass
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download