Chinaunix首页 | 论坛 | 博客
  • 博客访问: 925423
  • 博文数量: 264
  • 博客积分: 10107
  • 博客等级: 上将
  • 技术积分: 2455
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-09 16:34
文章分类

全部博文(264)

文章存档

2012年(1)

2011年(11)

2010年(128)

2009年(82)

2008年(42)

我的朋友

分类: 系统运维

2010-07-05 21:20:29

MyEclipse 7.5下安装反编译插件jad 收藏
      公司机器上装的Java开发环境是MyEclipse 7.5,因为懒的删掉再装Myeclipse 8.0,而今天又需要反编译某个jar包,就试着安装了反编译插件jad。
      MyEclipse 7.5版本自身提供了2种插件安装方法。第一种方法是:Help=>Software Updates=>Add/Remove Software菜单进去,选择要安装的插件压缩包或者在线安装URL,因为我用的反编译插件jad.zip是较早从网上下载的,找不到在线安装URL,解压出来的jar文件也不符合MyEclipse 7.5可安装压缩包的条件(具体条件我也不知道),所以方法一无效;第二种方法是:将插件(jar或目录格式)直接放入MyEclipse主目录的dropins目录中,重启一下MyEclipse即可,但不知道为什么试下来也无效。
      后来记得以前在网上看到过用程序生成配置文件信息的方法安装插件,就试了下,果然有效,具体代码如下:
view plaincopy to clipboardprint?
01.import java.io.File;  
02.import java.util.ArrayList;  
03.import java.util.List;  
04./** 
05. * MyEclipse 7.5 插件代码生成工具   
06. * 生成的代码放入 \configuration\org.eclipse.equinox.simpleconfigurator\bundles.info 
07. * 然后在命令提示符中使用 myeclipse.exe -clean 重启 或者关闭MyEclipse再打开即可 
08. * 
09. */ 
10.public class CreatePluginsConfig {  
11.    public CreatePluginsConfig() {  
12.    }  
13.    public void print(String path) {  
14.        List list = getFileList(path);  
15.        if (list == null) {  
16.            return;  
17.        }  
18.        int length = list.size();  
19.        for (int i = 0; i < length; i++) {  
20.        String result = "";  
21.        String thePath = getFormatPath(getString(list.get(i)));  
22.        File file = new File(thePath);  
23.        if (file.isDirectory()) {  
24.            String fileName = file.getName();  
25.            if (fileName.indexOf("_") < 0) {  
26.                print(thePath);  
27.                continue;  
28.            }  
29.            String[] filenames = fileName.split("_");  
30.            String filename1 = filenames[0];  
31.            String filename2 = filenames[1];  
32.            result = filename1 + "," + filename2 + ",file:/" + path + "\\" 
33.                + fileName + "";  
34.            System.out.println(result);  
35.        } else   
36.            if (file.isFile()) {  
37.                String fileName = file.getName();  
38.                if (fileName.indexOf("_") < 0) {  
39.                    continue;  
40.                }  
41.                int last = fileName.lastIndexOf("_");// 最后一个下划线的位置  
42.                String filename1 = fileName.substring(0, last);  
43.                String filename2 = fileName.substring(last + 1, fileName  
44.                    .length() - 4);  
45.                result = filename1 + "," + filename2 + ",file:/" + path + "\\" 
46.                    + fileName + ",4,false";  
47.                System.out.println(result);  
48.            }  
49.        }  
50.    }  
51.    public List getFileList(String path) {  
52.        path = getFormatPath(path);  
53.        path = path + "/";  
54.        File filePath = new File(path);  
55.        if (!filePath.isDirectory()) {  
56.            return null;  
57.        }  
58.        String[] filelist = filePath.list();  
59.        List filelistFilter = new ArrayList();  
60.        for (int i = 0; i < filelist.length; i++) {  
61.            String tempfilename = getFormatPath(path + filelist[i]);  
62.            filelistFilter.add(tempfilename);  
63.        }  
64.        return filelistFilter;  
65.     }  
66.    public String getString(Object object) {  
67.        if (object == null) {  
68.            return "";  
69.        }  
70.        return String.valueOf(object);  
71.    }  
72.    public String getFormatPath(String path) {  
73.        path = path.replaceAll("", "/");  
74.        path = path.replaceAll("//", "/");  
75.        return path;  
76.    }  
77.    public static void main(String[] args) {  
78.        // 插件文件所在目录结构是eclipse/features and plugins的形式  
79.        String plugin ="C:\\Program Files\\Genuitec\\MyEclipse 7.5\\jad";  
80.        new CreatePluginsConfig().print(plugin);  
81.    }  
82.} 
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
 * MyEclipse 7.5 插件代码生成工具 
 * 生成的代码放入 \configuration\org.eclipse.equinox.simpleconfigurator\bundles.info
 * 然后在命令提示符中使用 myeclipse.exe -clean 重启 或者关闭MyEclipse再打开即可
 *
 */
public class CreatePluginsConfig {
 public CreatePluginsConfig() {
 }
 public void print(String path) {
  List 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 + "";
   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 getFileList(String path) {
  path = getFormatPath(path);
  path = path + "/";
  File filePath = new File(path);
  if (!filePath.isDirectory()) {
   return null;
  }
  String[] filelist = filePath.list();
  List filelistFilter = new ArrayList();
  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) {
  // 插件文件所在目录结构是eclipse/features and plugins的形式
  String plugin ="C:\\Program Files\\Genuitec\\MyEclipse 7.5\\jad";
  new CreatePluginsConfig().print(plugin);
 }
}
执行程序并拷贝控制台输出,将其追加到%MYECLIPSE_HOME%\MyEclipse 7.5\\configuration\org.eclipse.equinox.simpleconfigurator\bundles.info文件末尾并保存,重启一下后就安装成功了。
 

MyEclipse 8.5 安装JAD
 
准备工作
   1. 下载jad.exe文件:
   2. 下载jadeclipse插件:
   3. JadClipse 官网:
安装
   1. 将jad.exe解压到指定目录。如:c:\java\jad
   2. 将jadeclipse插件net.sf.jadclipse_3.3.0.jar 拷贝到myeclipse安装目录\Genuitec\Common\plugins\目录下。
   3. 在myeclipse安装目录下dropins/创建eclipse文件夹,然后在eclipse文件夹中分别创建features、plugins文件夹,将net.sf.jadclipse_3.3.0.jar 分别拷贝到features和plugins文件夹中。
   4. 重新启动myeclipse后,配置jadeclipse插件
   5. 在eclipse窗口下,点击Window > Preferences > Java > JadClipse > Path to Decompiler。(设置jad的绝对路径,如 C:\java\Jad\jad.exe)。Use Eclipse code formatter(overrides Jad formatting instructions)选项打勾,与格式化出来的代码样式一致。
   6. 在eclipse窗口下,点击Window > Preferences > Java > JadClipse > Misc,将Convert Unicode strings into ANSI strings选项打勾,避免反编译后可能出现的中文乱码。
阅读(868) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~