I have a products.jar file. Inside that there is one class com.ClassA. The structure of the project is like
products
|--test
|--com
|--ClassA.java
|--dependencies
|---inputs.txt
Inside eclipse, ClassA.java is accessing the inputs.txt file by the following path and it is working fine
private static final String PROPERTIES_FILE_PATH = "test/dependencies/inputs.txt";
test package is in the java build path -> sources
But when I am exporting this project as products.jar, I find that in the jar file there is no test directory. There are two dirs com and dependencies at the root of the jar file. So when I am trying to execute the ClassA (residing in jar file) through command line, I am getting the following exception:
JUnit version 4.8.2
java.io.FileNotFoundException: test/dependencies/inputs.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at java.io.FileInputStream.<init>(FileInputStream.java:96)
So after finding that test dir is not being exported in jar file, I changed the path of the file in my ClassA.java to dependencies/inputs.txt. It didn't work in eclipse but I thought that it would work in jar because jar file is in classpath and dependencies folder is at the root of the jar file so the java launcher will be able to locate the dependencies folder and then inputs.txt file.
But unfortunately it is also not working.