Here is the structure of my project :
I need to read config.properties
inside MyClass.java
.
I tried to do so with a relative path as follows :
// Code called from MyClass.java
File f1 = new File("..\\..\\..\\config.properties");
String path = f1.getPath();
prop.load(new FileInputStream(path));
This gives me the following error :
..\..\..\config.properties (The system cannot find the file specified)
How can I define a relative path in Java? I'm using jdk 1.6 and working on windows.
config.properties
undersrc
. Createconfig
package undersrc
, keepconfig.properties
underconfig
package. And access simply it asconfig/config.properties
. – Tiltyardconfig.properties
be distributed with the Jar? If so it becomes an embedded-resource which is not accessible byFile
, but must instead be accessed byURL
. – Prospector