怎么把class文件反编译成java文件
发布时间:2025-05-20 23:51:48 发布人:远客网络
一、怎么把class文件反编译成java文件
Java中使用eclipse提供的插件对class进行反编译成java文件,如下步骤:
使用jadclipse插件一定要注意Eclipse版本。jadclipse_3.2.4,它对应的是Eclipse3.2版,jadclipse_3.3.0可以用于Eclipse3.3M6以上版。大家千万不要把jadclipse_3.3.0放到Eclipse3.2中,也不要把jadclipse_3.2.4放到Eclipse3.3中,将jadclipse插件(版本自己选择)直接copy到Eclipse目录中的plugins文件夹下,然后打开Eclipse,选择"窗口"-"首选项"-"常规"-"编辑器"-"文件关联",点击文件关联中的*.class,下面就会看到"JadClipse Class File Viewer",选中它,点击缺省值,点击OK,将它设置为默认的类查看器。如图:
另外在用jadclipse的时候,一定要加入jad.exe这个程序,如果只有插件而没有jad,那么还是不能反编译成功,会显示如下所示的错误,因此我们还要安装jad。
可以在这个地址下载到最新的jad,而且有不同平台的版本,本文后面也有相关下载。将下载的压缩包解压后复制jad.exe至你的%JAVA_HOME%\bin目录下,这样做的好处是使用方便。然后在Eclipse中设置一下,选择”窗口”-“首选项”-“Java”-“JadClipse”,在path to decompiler中输入jad.exe的绝对路径。这样做是为了保证反编译的效果。大象做过测试,只要将jad.exe放入%JAVA_HOME%\bin目录下,就没问题了,这个地方不设置也没关系,不过本人还是建议大家设置一下,其它地方不用管。其实大象也不知道该怎么弄,就让它保持默认值好了。
到这里,工作就做完了,现在再来按住Ctrl,用鼠标点击Element,贴上部分反编译代码,如图:
二、java swing下拉框两级联动
1、我这里有一个省市联动,还有注释,楼主满意吗
2、<title>省市级联效果</title>
3、<script type="text/javascript">
4、 var province= document.getElementById("sltProvince").value;
5、//定义两个变量,代表下拉列表框的选项目(option)
6、//new Option("显示的值","value值")
7、 option1= new Option("武汉市","武汉市");
8、 option2= new Option("襄樊市","襄樊市");
9、 option1= new Option("成都市","成都市");
10、 option2= new Option("南充市","南充市");
11、 option1= new Option("广州市","广州市");
12、 option2= new Option("深圳市","深圳市");
13、//先把城市下拉框中的原有选项清空
14、//options:代表下拉框的选项数组
15、 document.getElementById("sltCity").options.length= 0;
16、//把新创建的选项添加到城市下拉框中
17、 document.getElementById("sltCity").options.add(option1);
18、 document.getElementById("sltCity").options.add(option2);
19、<select id="sltProvince" onchange="changeCity();">
20、<option>--请选择省份--</option>
21、<option value="湖北省">湖北省</option>
22、<option value="四川省">四川省</option>
23、<option value="广东省">广东省</option>
24、<option>--请选择城市--</option>
三、java的一个简单记事本程序设计
是记事本的样式吗?就要这些要求吗?
下面这些代码的功能挺全的,可以参考一下,不用的可以删掉。
public class NoteBook extends JFrame implements ActionListener,ItemListener,WindowListener,MouseListener
{ Container c= this.getContentPane();
JMenuBar jmb= new JMenuBar();
JColorChooser jcl= new JColorChooser();
JToolBar jToolBar= new JToolBar();
JButton jButton1= new JButton();
JButton jButton2= new JButton();
JButton jButton3= new JButton();
JButton jButton4= new JButton();
JMenu jm1= new JMenu("文件(F)");
JMenu jm2= new JMenu("编辑(E)");
JMenu jm4= new JMenu("格式(O)");
JMenu jm5= new JMenu("查看(V)");
JMenu jm3= new JMenu("帮助(H)");
JMenuItem jmi1= new JMenuItem("新建(N)");
JMenuItem jmi2= new JMenuItem("打开(O)");
JMenuItem jmi3= new JMenuItem("保存(S)");
JMenuItem jmi4= new JMenuItem("退出(X)");
JMenu jmd4=new JMenu("颜色");
JMenu jmd0=new JMenu("字体");
JMenuItem aa=new JMenuItem("复制(C)");
JMenuItem bb=new JMenuItem("剪切(X)");
JMenuItem cc=new JMenuItem("粘贴(V)");
JCheckBoxMenuItem jcuti1= new JCheckBoxMenuItem("粗体");
JCheckBoxMenuItem jxieti1= new JCheckBoxMenuItem("斜体");
JMenuItem jmp1= new JMenuItem("日期和时间");
JMenuItem jmp2= new JMenuItem("背景颜色(H)");
JMenuItem jmi5= new JMenuItem("删除内容(S)");
JMenuItem jmi7=new JMenuItem("关于自己");
JTextArea jta= new JTextArea(23,15);
JScrollPane jsp= new JScrollPane(jta);
JMenuItem jmdb1=new JMenuItem("黄色");//定义各种颜色
JMenuItem jmdb2=new JMenuItem("红色");
JMenuItem jmdb3=new JMenuItem("绿色");
JMenuItem jmdb4=new JMenuItem("蓝色");
JMenuItem jmdb5=new JMenuItem("黑色");
{ this.addWindowListener(this);
c.add(jmb,BorderLayout.NORTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jm5.setMnemonic('v');//查看
jmi1.addActionListener(this);//新建
jmi1.setAccelerator(KeyStroke.getKeyStroke('N',Event.CTRL_MASK,false));
jmi2.setAccelerator(KeyStroke.getKeyStroke('O',Event.CTRL_MASK,false));
jmi2.addActionListener(this);//打开
jmi3.setAccelerator(KeyStroke.getKeyStroke('S',Event.CTRL_MASK,false));
jmi3.addActionListener(this);//保存
jmi1.setMnemonic('n');
jmi2.setMnemonic('o');
jmi3.setMnemonic('s');
jmi4.setMnemonic('x');
jmi4.addActionListener(this);//退出
jmd4.addActionListener(this);//添加监视器
jmdb1.addActionListener(this);
jmdb2.addActionListener(this);
jmdb3.addActionListener(this);
jmdb4.addActionListener(this);
jmdb5.addActionListener(this);
jmp1.addActionListener(this);//日期时间
jmp2.addActionListener(this);//背景颜色
aa.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_MASK));
bb.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_MASK));
cc.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,InputEvent.CTRL_MASK));
aa.addActionListener(this);//复制
bb.addActionListener(this);//剪切
cc.addActionListener(this);//粘贴
jcuti1.addItemListener(this);//粗体
jxieti1.addItemListener(this);//斜体
jmi7.addActionListener(this);//关于自己
c.add(jToolBar,BorderLayout.CENTER);//工具条
jButton2.setIcon(new ImageIcon("image\\new.JPG"));//新建
jButton2.setToolTipText("新建");
jButton2.addActionListener(this);
jButton1.setIcon(new ImageIcon("image\\open.JPG"));//打开
jButton1.setToolTipText("打开");
jButton1.addActionListener(this);
jButton3.setIcon(new ImageIcon("image\\save.JPG"));//保存
jButton3.setToolTipText("保存");
jButton3.addActionListener(this);
jButton4.setIcon(new ImageIcon("image\\qq.JPG"));
jButton4.addActionListener(this);//退出
jButton4.setToolTipText("退出");
c.add(jsp,BorderLayout.SOUTH);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
jmdb1.addActionListener(new ActionListener()//黄色
{ public void actionPerformed(ActionEvent e)
{ jta.setForeground(Color.yellow);
jmdb2.addActionListener(new ActionListener()//红色
{ public void actionPerformed(ActionEvent e)
{ jta.setForeground(Color.red);
jmdb3.addActionListener(new ActionListener()//绿色
{ public void actionPerformed(ActionEvent e)
{ jta.setForeground(Color.green);
jmdb4.addActionListener(new ActionListener()//蓝色
public void actionPerformed(ActionEvent e)
jta.setForeground(Color.blue);
jmdb5.addActionListener(new ActionListener()//黑色
public void actionPerformed(ActionEvent e)
jta.setForeground(Color.black);
public void actionPerformed(ActionEvent e)
{ if(e.getSource()==jmi1)//新建
this.setTitle("无标题-记事本");
JFileChooser jfc1= new JFileChooser();
int num1= jfc1.showOpenDialog(this);
if(num1==JFileChooser.APPROVE_OPTION)
FileReader fr= new FileReader(f1);
BufferedReader br= new BufferedReader(fr);
while((str= br.readLine())!=null)
catch(FileNotFoundException e1)
catch(IOException e2){e2.printStackTrace();}
JFileChooser jfc2= new JFileChooser();
int num2= jfc2.showSaveDialog(this);
if(num2==JFileChooser.APPROVE_OPTION){
FileWriter fw= new FileWriter(f2);
BufferedWriter bw= new BufferedWriter(fw);
int a= JOptionPane.showConfirmDialog(this,"文件已被改变,是否要保存?","提示",JOptionPane.YES_NO_CANCEL_OPTION);
JFileChooser jfc2= new JFileChooser();
int num2= jfc2.showSaveDialog(this);
if(num2==JFileChooser.APPROVE_OPTION){
FileWriter fw= new FileWriter(f2);
BufferedWriter bw= new BufferedWriter(fw);
if(e.getSource()==jmp1)//日期时间
Calendar c1=Calendar.getInstance();
int m= c1.get(Calendar.MONTH);
int m1= c1.get(Calendar.MINUTE);
jta.setText(y+"年"+m2+"月"+d+"日"+h+":"+m1);
if(e.getSource()==jmp2)//背景色
{ Color ccc= JColorChooser.showDialog(this,"color",Color.BLACK);
jta.setSelectedTextColor(ccc);
if(e.getSource()==jButton1)//打开
JFileChooser jfc1= new JFileChooser();
int num1= jfc1.showOpenDialog(this);
if(num1==JFileChooser.APPROVE_OPTION)
FileReader fr= new FileReader(f1);
BufferedReader br= new BufferedReader(fr);
while((str= br.readLine())!=null)
catch(FileNotFoundException e1)
catch(IOException e2){e2.printStackTrace();}
jta.replaceRange("",jta.getSelectionStart(),jta.getSelectionEnd());//删除
JFileChooser jfc2= new JFileChooser();
int num2= jfc2.showSaveDialog(this);
if(num2==JFileChooser.APPROVE_OPTION){
FileWriter fw= new FileWriter(f2);
BufferedWriter bw= new BufferedWriter(fw);
else if(e.getSource()==bb)//剪切
else if(e.getSource()==cc)//粘贴
{int a= JOptionPane.showConfirmDialog(this,"文件已被改变,是否要保存?","提示",JOptionPane.YES_NO_CANCEL_OPTION);
JFileChooser jfc2= new JFileChooser();
int num2= jfc2.showSaveDialog(this);
if(num2==JFileChooser.APPROVE_OPTION){
FileWriter fw= new FileWriter(f2);
BufferedWriter bw= new BufferedWriter(fw);
//if(e.getSource()==jmi7)//关于我
//{About1 a=new About1();//实现跳转
public void itemStateChanged(ItemEvent e)//字体
{Font c=new Font("Serif",Font.PLAIN,14);
if(e.getItemSelectable()==jcuti1)
{ Font f=new Font("Serif",Font.BOLD,20);//粗体
else if(e.getItemSelectable()==jxieti1)
{ Font b=new Font("Serif",Font.ITALIC,20);//斜体
public static void main(String[] args)//入口
public void windowOpened(WindowEvent arg0){}
public void windowClosing(WindowEvent arg0){
int a= JOptionPane.showConfirmDialog(this,"文件已被改变,是否要保存?","提示",JOptionPane.YES_NO_CANCEL_OPTION);
JFileChooser jfc2= new JFileChooser();
int num2= jfc2.showSaveDialog(this);
if(num2==JFileChooser.APPROVE_OPTION){
FileWriter fw= new FileWriter(f2);
BufferedWriter bw= new BufferedWriter(fw);
public void windowClosed(WindowEvent arg0){}
public void windowIconified(WindowEvent arg0){}
public void windowDeiconified(WindowEvent arg0){}
public void windowActivated(WindowEvent arg0){}
public void windowDeactivated(WindowEvent arg0){}
public void mouseClicked(MouseEvent arg0){}
public void mousePressed(MouseEvent arg0){}
public void mouseReleased(MouseEvent arg0){}
public void mouseEntered(MouseEvent arg0){}
public void mouseExited(MouseEvent arg0){}