如何在MyEclipse10中配置Jad反编译工具?

原网址:http://blog.csdn.net/qq_29829081/article/details/51068570

  在学习编程的过程当中,我们需要经常看一些源码。一般情况下,我们都需要导入源码,才能打开项目中jar包里面的class文件,但是这样操作非常麻烦,如果不用关联源码就可以查看源码,会大大提高学习效率。因此,我们就需要在开发工具中配置反编译工具。我在网上搜了很多资料,结果都配置失败,最后有一篇博客(http://blog.csdn.net/yjhandyw/article/details/21083071#comments)给了启发,最后在MyEclipse10当中配置成功。现在就将自己的一点经验分享给大家,希望对大家有所帮助。

例如:一个web项目当中我们导入了很多jar包,里面的class文件都不能读取源码!点击之后如下图所示:


MyEclipse10当中配置Jad反编译工具的步骤:

1、下载jad.exe和net.sf.jadclipse_3.3.0.jar文件。

2、将下载的jad反编译相关文件.rar文件解压,并将jad.exe文件复制到jdk的安装目录下的jre文件夹下。例如:D:\develop\Java\jre7\bin\jad.exe。


3、将net.sf.jadclipse.3.3.0.jar文件复制到MyEclipse的安装目录下。

  • 在安装目录里面新建dropins文件夹,如果有dropins文件夹则不需要新建。
  • 在dropins文件夹下面新建features文件夹和plugins文件夹。
  • 将net.sf.jadclipse.3.3.0.jar分别复制到features文件夹和plugins文件夹(不复制到这个文件夹,不会生成JadClipse)。

4、创建一个java项目,将下面的代码复制(引用自http://blog.csdn.net/yjhandyw/article/details/21083071#comments)进去直接运行。

注意:将这里的路径替换成自己插件的安装目录,例如我的是"D:\\develop\\MyEclipse 10\\dropins\\plugins"。

运行CreatePluginsConfig.java
 
  
import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * MyEclipse10.0 插件配置代码生成器
 */

public class CreatePluginsConfig {

	public CreatePluginsConfig() {
	}

	public void print(String path) {
		List<String> list = getFileList(path);
		if (list == null) {
			return;
		}

		int length = list.size();
		for (int i = 0; i < length; i++) {
			String result = "";
			String thePath = getFormatPath(getString(list.get(i)));
			File file = new File(thePath);
			if (file.isDirectory()) {
				String fileName = file.getName();
				if (fileName.indexOf("_") < 0) {
					print(thePath);
					continue;
				}
				String[] filenames = fileName.split("_");
				String filename1 = filenames[0];
				String filename2 = filenames[1];
				result = filename1 + "," + filename2 + ",file:/" + path + "\\"
						+ fileName + "\\,4,false";
				System.out.println(result);
			} else if (file.isFile()) {
				String fileName = file.getName();
				if (fileName.indexOf("_") < 0) {
					continue;
				}
				int last = fileName.lastIndexOf("_");
				String filename1 = fileName.substring(0, last);
				String filename2 = fileName.substring(last + 1,
						fileName.length() - 4);
				result = filename1 + "," + filename2 + ",file:/" + path + "\\"
						+ fileName + ",4,false";
				System.out.println(result);
			}

		}
	}

	public List<String> getFileList(String path) {
		path = getFormatPath(path);
		path = path + "/";
		File filePath = new File(path);
		if (!filePath.isDirectory()) {
			return null;
		}
		String[] filelist = filePath.list();
		List<String> filelistFilter = new ArrayList<String>();

		for (int i = 0; i < filelist.length; i++) {
			String tempfilename = getFormatPath(path + filelist[i]);
			filelistFilter.add(tempfilename);
		}
		return filelistFilter;
	}

	public String getString(Object object) {
		if (object == null) {
			return "";
		}
		return String.valueOf(object);
	}

	public String getFormatPath(String path) {
		path = path.replaceAll("\\\\", "/");
		path = path.replaceAll("//", "/");
		return path;
	}

	public static void main(String[] args) {
		// 将这里的路径替换成自己插件的安装目录,例如我的是"D:\\develop\\MyEclipse 10\\dropins\\plugins"
		String plugin = "D:\\develop\\MyEclipse 10\\dropins\\plugins";
		new CreatePluginsConfig().print(plugin);
	}
}

 
  
 
  
 
 

运行结果:

net.sf.jadclipse,3.3.0,file:/D:\develop\MyEclipse 10\dropins\plugins\net.sf.jadclipse_3.3.0.jar,4,false


5、找到MyEclipse10安装目录下的org.eclipse.equinox.simpleconfigurators文件夹下面的bundles.info文件,用记事本打开,将上面程序的运行结果加入到文件最后,并保存。 

例如:D:\develop\MyEclipse 10\configuration\org.eclipse.equinox.simpleconfigurator\bundles.info


6、重启MyEclipse10,进行配置 JadClipse。

            在MyEclipse10中,打开Windows---> Perferences--->General--->Editors--->File Association,选择*.class(如果没有的话就自己点击Add添加一个),在下面的Associated editors中将JadClipse Class File Viewer设置为默认(default)。如下图所示:


7、在MyEclipse中设置JadClipse的Path to decompiler和Directory for temporary files。

  • 在MyEclipse10中,打开Windows---> Perferences--->Java--->JadClipse,按照下图填写路径名称,格式最好一致,同时选中Use Eclipse code formatter (overrides Jad formatting instructions)。

       

  • 在MyEclipse10中,打开Windows---> Perferences--->Java--->JadClipse--->Misc,选中Convert Unicode strings into ANSI strings,这个选项主要是防止乱码的。


                                                        配置完以上这些,就可以点开class文件了,希望对大家有所帮助!





猜你喜欢

转载自blog.csdn.net/baidu_33320352/article/details/71107115