I am writing a library that contains references to a few non-java binary files. (The java library is used to make sub-proc calls to these).
I has specified the path to the folder containing these files using this line of code:
String binaryFolder = System.getProperty("user.dir") + "/externalbinaries/";
Of course this path does not hold when the library is included in another java application.
Is there a way to specify the path relative to the project root?
I have seen answers using the classloader:
binaryFolder = classLoader.getResource("bin/ext/").getPath();
but this path to the resource folder also does not hold when imported as a .jar library in an application.
I am using java 1.8.
Any ideas?
what you describe with the user.dir is not really a relative path, because the result of that statement is actually an absolute path, but it is not a "fixed" path because the user working directory can change, i assume thats what you meant with "relative"?
what about user.home instead, that should be a fixed path?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.