I have a project structure where the resources folder is at the same level as src. The resources folder has got a subfolder config, which has a configuration file conffile.ttl. I have included the resources in the classpath while running the program from eclipse.
While reading the conffile.ttl file from my main class, I use
URL url =TestPropertyFilePath.class.getClassLoader().getSystemResource("conf/conffile.ttl");
System.out.println(url.getPath());
which works fine. However when I bundle this in a jar and try to run the jar using
java -jar testprop.jar TestPropertyFilePath
Java cannot find the conffile.ttl file. I would like advice on how to access the conffile.ttl from within the jar.
尝试这个:
TestPropertyFilePath.class.getClassLoader().getSystemResource("conf.conffile");
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.