I´m developing a web project in eclipse with a servlet in the backend (using tomcat 8). In the servlet i want to reference two large files which contain data that should be read. Until now i was just using hardcoded filepaths as strings to reference the files , e.g. like this: "C:\\data\\file1"
I want to store the files within the project, so that the relative path to them stays the same no matter on which computer i´m running the application.
This subject came up sometimes here and i´ve tried out things like
System.getProperty("catalina.base");
or
System.getProperty("user.dir");
but both methods point to completely different locations then where my files are stored.
So if the file is stored in the project like this:
"server\\webapps\\project\\data\\file1"
and the servlet is contained in the package folder with the other .java files, how can i get the path to file1
as a string?