Java中获取类路径classpath的简单方法(推荐)
程序员文章站
2024-03-12 20:45:32
如下所示:
system.out.println("++++++++++++++++...
如下所示:
<span style="font-size: 18px"> system.out.println("++++++++++++++++++++++++"); string path = system.getproperty("java.class.path"); string path2 = freemarkerwriter.class.getprotectiondomain().getcodesource().getlocation().getpath(); string path3 = freemarkerwriter.class.getprotectiondomain().getcodesource().getlocation().getfile(); string path4 = thread.currentthread().getcontextclassloader().getresource("").getpath(); system.out.println("path 1 = " + path); system.out.println("path 2 = " + path2); system.out.println("path 3 = " + path3); system.out.println("path 4 = " + path4); system.out.println("++++++++++++++++++++++++"); </span>
以上这篇java中获取类路径classpath的简单方法(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。