当前位置: 移动技术网 > IT编程>开发语言>Java > Java中获取类路径classpath的简单方法(推荐)

Java中获取类路径classpath的简单方法(推荐)

2019年07月22日  | 移动技术网IT编程  | 我要评论

如下所示:

<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的简单方法(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网