java 检测class文件走哪个jar包的代码
1个回答
展开全部
ClassLoader classloader =
org.apache.poi.poifs.filesystem.POIFSFileSystem.class.getClassLoader();
URL res = classloader.getResource(
"org/apache/poi/poifs/filesystem/POIFSFileSystem.class");
String path = res.getPath();
System.out.println("POI Core came from " + path);
classloader = org.apache.poi.POIXMLDocument.class.getClassLoader();
res = classloader.getResource("org/apache/poi/POIXMLDocument.class");
path = res.getPath();
System.out.println("POI OOXML came from " + path);
classloader = org.apache.poi.hslf.HSLFSlideShow.class.getClassLoader();
res = classloader.getResource("org/apache/poi/hslf/HSLFSlideShow.class");
path = res.getPath();
System.out.println("POI Scratchpad came from " + path);
检测后,发现确实有一个class走了老包,只删java build path没生效。后来把workspace里面的包删了再把project clean一下,然后重新部署,OK,问题解决了!
org.apache.poi.poifs.filesystem.POIFSFileSystem.class.getClassLoader();
URL res = classloader.getResource(
"org/apache/poi/poifs/filesystem/POIFSFileSystem.class");
String path = res.getPath();
System.out.println("POI Core came from " + path);
classloader = org.apache.poi.POIXMLDocument.class.getClassLoader();
res = classloader.getResource("org/apache/poi/POIXMLDocument.class");
path = res.getPath();
System.out.println("POI OOXML came from " + path);
classloader = org.apache.poi.hslf.HSLFSlideShow.class.getClassLoader();
res = classloader.getResource("org/apache/poi/hslf/HSLFSlideShow.class");
path = res.getPath();
System.out.println("POI Scratchpad came from " + path);
检测后,发现确实有一个class走了老包,只删java build path没生效。后来把workspace里面的包删了再把project clean一下,然后重新部署,OK,问题解决了!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询