I have a Java project in Eclipse IDE. If I create new File object. Like File file = new File("someFile.txt")
. It expects someFile.txt to be present in project home. And I can put it in some directory like config/someFile.txt
and can use this in new File constructor. All good here.
When I make the JAR of this project and put it in WEB-INF/lib. Then new File("someFile.txt")
code expects the file in TOMCAT_HOME/bin. I checked it with file.getAbsolutePath();
. It is out of my control. My question is why in java web application new File expects to be in the bin director. Why not the the project home. So that i can navigate to my configuration dir easily. Even ../../
navigation also does not work. Because they are getting appended with TOMCAT_HOME/bin/../../someFile.txt
and cause File Not Exist.
I hope I have explained well my problem.