如何在项目中查找冲突的类
来源:互联网 发布:linux设置ftp目录权限 编辑:程序博客网 时间:2024/05/29 02:47
代码分享地址:java如何在项目依赖的jar包中查找冲突的类
经常在项目中遇到冲突的jar文件。
使用这个方法可以在本地或者服务器上面查找冲突的类。支持模糊查找。
下载地址:http://www.zuidaima.com/share/1785617759915008.htm
方便实用的工具,留存备用。
package com.whaty.util;import java.util.*;import java.io.*;public class JarClassFind {public static int count = 0;static public void main(String[] args) {/* * if (args.length < 2) { showHowToUsage(); return; } */String className = "XMLParser"; // 要查询的class,模糊类名,凡是类名包括XMLParser的都会查询出来//String className="com/lowagie/text/xml/simpleparser/SimpleXMLParser";//指定具体包的类名,当多个类冲突时可以指定包排除String libPath = "E:\\STS\\jngl_mysql\\WebRoot"; // 所要查找的JAR包的目录,如果是linux目录记得将下面的\\换成/String absoluteclassname = className.replace('.', '/') + ".class";System.out.println("Find class [" + className + "] in Path [" + libPath + "] Results:");FindClassInLocalSystem(libPath, absoluteclassname);if (JarClassFind.count == 0) {System.out.println("Error:Can't Find Such Jar File!");}System.out.println("Find Process Ended! Total Results:" + JarClassFind.count);}private static void FindClassInLocalSystem(String path, String classname) {if (path.charAt(path.length() - 1) != '\\') {path += '\\';//linux下面换成/}File file = new File(path);if (!file.exists()) {System.out.println("Error: Path not Existed! Please Check it out!");return;}String[] filelist = file.list();for (int i = 0; i < filelist.length; i++) {File temp = new File(path + filelist[i]);if ((temp.isDirectory() && !temp.isHidden() && temp.exists())) {FindClassInLocalSystem(path + filelist[i], classname);} else {if (filelist[i].endsWith("jar")) {try {java.util.jar.JarFile jarfile = new java.util.jar.JarFile(path + filelist[i]);for (Enumeration e = jarfile.entries(); e.hasMoreElements();) {String name = e.nextElement().toString();if (name.equals(classname) || name.indexOf(classname) > -1) {System.out.println("No." + ++JarClassFind.count);System.out.println("Jar Package:" + path + filelist[i]);System.out.println(name);}}} catch (Exception eee) {}}}}}public static void showHowToUsage() {System.out.println("Usage: Java -cp. JarClassFind <source path> <source class name>");System.out.println("Usage: Java -classpath. JarClassFind <source path> <source class name>");System.out.println("");System.out.println("<source path>:\t\tPath to Find eg:D:\\Jbuilder");System.out.println("<source class name>:\tClass to Find eg:java.applet.Applet");}}
1 0
- 如何在项目中查找冲突的类
- java如何在项目依赖的jar包中查找冲突的类
- 在eclipse中如何在大量项目中查找指定文件
- 在eclipse中如何在大量项目中查找指定文件
- 在eclipse中如何在大量项目中查找指定文件
- 在eclipse中如何在大量项目中查找指定文件
- 在eclipse中如何在大量项目中查找指定文件
- 在eclipse中如何在大量项目中查找指定文件
- 在eclipse中如何在大量项目中查找指定文件
- 如何在list中查找
- 如何在Excel的一列中查找重复的数据
- 如何在Myeclipse中一个整个项目中查找某一个单词 thanks
- 如何在正则表达式中完成特定数字的查找
- 如何在Ubuntu中查找自己安装的软件包
- 如何在项目中查找内存泄漏以及有哪些帮助工具?
- 在Xcode项目中查找指定单词
- 在SharePoint2013中查找最受欢迎项目
- phpstorm在项目中查找某个字符串
- 基于java的linux线程监控
- 分布式系统------概述
- Java中动态加载class机制实验
- ContentProvider原理及实例 .
- strstr
- 如何在项目中查找冲突的类
- JavaScrpit 运算符
- 车牌识别系统开发记录(四) 国内车牌特点
- Android基础之 用Eclipse搭建Android开发环境和创建第一个Android项目
- OpenGL Shader Builder 使用简介
- SuSE Linux上修改主机名
- WP手机升级到WP8.1之后一些功能的吐槽和没有Cortana,改变绿色图标的问题的解决方案以及怎样调戏Cortana
- C中的 strftime , memcpy
- UITextField抖动动画