`
mengdejun
  • 浏览: 405393 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

java反编译程序

阅读更多

package com.mdj.test;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;

import com.mdj.unmake.Main;
/**
*
* @author 武汉软件工程职业学院<br>孟德军
* @version 1.0
*/
public class Start extends JFrame {
private JWindow window;
private String filepath;

public Start() {
filepath = System.getProperty("user.dir");
window = new JWindow(this);
Image logo = Toolkit.getDefaultToolkit().getImage(
filepath + "
//start.jpg");
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();

JPanel p = new JPanel(new GridLayout(2,2));
JLabel a = new JLabel("******** 欢迎使用本软件,/n 版权所有:孟德军 *********",
JLabel.CENTER);
a.setFont(new Font("宋体",Font.ITALIC,16));
JLabel b = new JLabel(new ImageIcon(logo), JLabel.CENTER);

p.add(b);
p.add(a);

window.add(p, "Center");

window.setLocation(scrSize.width /5, scrSize.height / 4);
window.setSize(scrSize.width / 3 + 50, scrSize.height / 3);
window.show();
window.toFront();
try {
Thread.currentThread().sleep(2000);
// Thread.currentThread();可以获得主线程的一个应用。
Main main = new Main("java反编译程序");
main.setVisible(true);

} catch (Exception e) {
e.printStackTrace();
}
window.dispose();

}

public static void main(String args[]) {
System.out.println("server start...please wait a minute!");
new Start();
}
}
///////////////////////////////////////////////////////
package com.mdj.unmake;

import java.awt.Toolkit;

public class Share {
public static final int SCREENHEIGHT = Toolkit.getDefaultToolkit()
.getScreenSize().height;
public static final int SCREENWIDTH = Toolkit.getDefaultToolkit()
.getScreenSize().width;
}
///////////////////////////////////////////////////////
package com.mdj.unmake;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Image;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.TextArea;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Date;

import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

public class Main extends JFrame {
private TextArea textarea;
private MenuBar mainbar;
private JScrollPane c;
private Menu file, edit, view, help;
private MenuItem load, save, exit, all, copy, fresh, about, back, font,
system, open;
private Font f;
private Toolkit tk;

public Main(String title) {
super(title);
tk = Toolkit.getDefaultToolkit();
Image image = tk.createImage(System.getProperty("user.dir")
+ "//logo.gif"); /* image.gif是你的图标 */
this.setIconImage(image);
init();
display();
this.add(textarea);
// this.add(sb);
this.setMenuBar(mainbar);
this.setSize(Share.SCREENWIDTH / 2, Share.SCREENHEIGHT / 2);
this.setLocation(Share.SCREENWIDTH / 4, Share.SCREENHEIGHT / 4);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
load.addActionListener(new Listener());
save.addActionListener(new Listener());
exit.addActionListener(new Listener());
all.addActionListener(new Listener());
copy.addActionListener(new Listener());
fresh.addActionListener(new Listener());
about.addActionListener(new Listener());
open.addActionListener(new Listener());
back.addActionListener(new Listener());
system.addActionListener(new Listener());
}

private void init() {
Cursor cursor = new Cursor(Cursor.HAND_CURSOR);
f = new Font("宋体", Font.PLAIN, 13);
Font fontset = new Font("宋体", Font.LAYOUT_LEFT_TO_RIGHT, 18);
textarea = new TextArea();
textarea.setFont(fontset);
textarea.setCursor(cursor);
mainbar = new MenuBar();
file = new Menu("文件");
edit = new Menu("编辑");
view = new Menu("视图");
help = new Menu("帮助");
open = new MenuItem("打开");
load = new MenuItem("加载");
save = new MenuItem("保存");
exit = new MenuItem("退出");
all = new MenuItem("全选");
copy = new MenuItem("复制");
fresh = new MenuItem("刷新");
about = new MenuItem("关于");
back = new MenuItem("背景色");
font = new MenuItem("字体");
system = new MenuItem("系统信息");
c = new JScrollPane();
file.setFont(f);
open.setFont(f);
edit.setFont(f);
view.setFont(f);
help.setFont(f);
load.setFont(f);
save.setFont(f);
exit.setFont(f);
copy.setFont(f);
all.setFont(f);
fresh.setFont(f);
about.setFont(f);
back.setFont(f);
font.setFont(f);

system.setFont(f);
// textarea.add(c);
}

public void display() {
mainbar.add(file);
mainbar.add(edit);
mainbar.add(view);
mainbar.add(help);
file.add(load);
file.add(open);
file.add(save);
file.add(exit);
edit.add(all);
edit.add(copy);
edit.add(fresh);
view.add(back);
edit.add(font);
help.add(about);
help.add(system);
}

/*
* public static void main(String args[]) { Main main = new
* Main("java反编译程序"); main.setVisible(true); }
*/

private class Listener implements ActionListener {

public void actionPerformed(ActionEvent s) {
while (s.getSource() == load) {
System.out.println("load");
loadClick();
break;
}
while (s.getSource() == save) {
System.out.println("save");
saveClick();
break;
}
while (s.getSource() == exit) {
System.out.println("exit");
System.exit(0);
}
while (s.getSource() == about) {
JOptionPane.showMessageDialog(null,
"该软件由java编写,开发平台为myeclipse /n 希望大家多多支持!/t 孟德军", "关于",
JOptionPane.INFORMATION_MESSAGE);
break;
}
while (s.getSource() == back) {
colorSet();
break;
}
while (s.getSource() == system) {
systemInformation();
break;
}
while (s.getSource() == font) {
new FontDialog().setVisible(true);
}
while (s.getSource() == open) {
openClick();
break;
}
}

/*
* private void copySet(){ String temp=textarea.getSelectedText();
* //拖动鼠标选取文本。 String Selection text=new String Selection(temp);
* clipboard.setContents(text,null); }
*/
private void colorSet() {
Color newcolor = JColorChooser.showDialog(null, "颜色设置", null);
textarea.setBackground(newcolor);
// textarea.setCursor(new Cursor().getDefaultCursor());

}

private void loadClick() {
Input myinput = new Input();
myinput.setVisible(true);
}

private void openClick() {
JFileChooser jfile = new JFileChooser();
jfile.setFileFilter(new javax.swing.filechooser.FileFilter() {
public boolean accept(File f) { // 设定可用的文件的后缀名
if (f.getName().endsWith(".java") || f.isDirectory()) {
return true;
}
return false;
}

public String getDescription() {
return "文本文件(*.txt)";
}
});
int result = jfile.showOpenDialog(null);
if (result == JFileChooser.OPEN_DIALOG) {
File dir = jfile.getCurrentDirectory();
File file = jfile.getSelectedFile();
textarea.setText(readFile(new File(dir, file.getName())));
// System.out.println(readFile(new File(dir, file.getName())));
} else if (result == JFileChooser.CANCEL_OPTION) {
return;
}

}

private String readFile(File file) {
System.out.println("readfile...");
try {
BufferedReader read = new BufferedReader(new InputStreamReader(
new FileInputStream(file), "GBK"));
String data = null;
StringBuffer buffer = new StringBuffer();
while ((data = read.readLine()) != null) {
buffer.append(data + "/n");
}
read.close();
return buffer.toString();
} catch (IOException e) {
throw new RuntimeException(e);
}

}

private void systemInformation() {
Runtime rt = Runtime.getRuntime();
JOptionPane.showConfirmDialog(null, "剩余内存: " + rt.freeMemory()
+ " KB" + "/n" + "总内存: " + rt.totalMemory() + " KB",
"系统信息", JOptionPane.OK_OPTION, JOptionPane.WARNING_MESSAGE);

}

private void saveClick() {
// 该方法用于保存文件。
JFileChooser jfile = new JFileChooser();
jfile.setFileFilter(new javax.swing.filechooser.FileFilter() {
public boolean accept(File f) { // 设定可用的文件的后缀名
if (f.getName().endsWith(".java") || f.isDirectory()) {
return true;
}
return false;
}

public String getDescription() {
return "文本文件(*.txt)";
}
});
int result = jfile.showSaveDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
File dir = jfile.getCurrentDirectory();
File file = jfile.getSelectedFile();
write(new File(dir, file.getName() + ".txt"), textarea
.getText());

}
if (result == JFileChooser.CANCEL_OPTION) {
return;
}

}

public void write(File file, String str) {
try {
PrintWriter write = new PrintWriter(new OutputStreamWriter(
new FileOutputStream(file), "UTF-8"));
write.println(str);
write.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

}

private class Input extends JFrame {
private JLabel classname;
private JTextField classnametext;
private JButton okbutton, cancelbutton;
private Toolkit tcl;

public Input() {
init();
tcl = Toolkit.getDefaultToolkit();
Image image = tcl.createImage(System.getProperty("user.dir")
+ "//logo.gif");
this.setIconImage(image);
this.setSize(250, 100);
this.setLocation(Share.SCREENWIDTH / 4, Share.SCREENHEIGHT / 4);
this.setTitle("请输入完整类名");
this.add(classname);
this.add(classnametext);
this.add(okbutton);
this.add(cancelbutton);
this.setLayout(new FlowLayout());
this.setResizable(false);
cancelbutton.addActionListener(new InputClick());
okbutton.addActionListener(new InputClick());

}

private void init() {
Font f = new Font("宋体", Font.PLAIN, 14);
classname = new JLabel("类名称");
classnametext = new JTextField(20);
okbutton = new JButton("确定");
cancelbutton = new JButton("取消");
okbutton.setMnemonic('y');
cancelbutton.setMnemonic('n');
classname.setFont(f);
okbutton.setFont(f);
cancelbutton.setFont(f);
classnametext.setFont(f);
}

private void loading() {
StringBuffer buffer = new StringBuffer();
System.out.println("loading");
try {
Class classtype = Class.forName(classnametext.getText());
Object instance = classtype.newInstance();
System.out.println(checkClass(classtype.getName()));
System.out.println(checkEmbelLKish(classtype.getName()));
buffer.append("public class " + instance.getClass().getName()
+ "{/n/n");
Field[] field = classtype.getDeclaredFields();
for (int i = 0; i < field.length; i++) {
buffer.append(field[i].toString());
buffer.append(";/n/n");
}
Constructor[] con = classtype.getConstructors();
for (int i = 0; i < con.length; i++) {
buffer.append(con[i].toString());
buffer.append("/n{/n");
buffer.append("// TODO Auto-generated method stub/n");
buffer.append("}/n");
}
Method[] mehtod = classtype.getDeclaredMethods();
for (int x = 0; x < mehtod.length; x++) {
buffer.append("/n");
buffer.append(mehtod[x].toString());
buffer.append("{/n/n");
buffer.append("// TODO Auto-generated method stub/n");
buffer.append("}/n");
}
buffer.append("/n/n}");
buffer
.append("/n/n/** This program copyright by xiaomeng /n/n
mak0000@msn.com **//n");
buffer.append("/n///tTHE TIME:" + new Date());
textarea.setText(buffer.toString());
} catch (ClassNotFoundException e) {
showMessage(e.getMessage()
+ "/nClassNotFoundException,please check the classname");
} catch (InstantiationException e) {
showMessage(e.getMessage()
+ "/nInstantiationException,please check the classname");
} catch (IllegalAccessException e) {
showMessage(e.getMessage()
+ "/nIllegalAccessException,please check the classname");
}
}

private String checkClass(String s) {
int a = 0;
String sub = null;
int b = s.lastIndexOf(".");
if (b != 0) {
a = s.length();
sub = s.substring(b + 1, a);
}
return sub;
}

private String checkEmbelLKish(String s) {
int a = 0;
String sub = null;
int b = s.indexOf(".");
if (b != 0) {
a = s.length();
sub = s.substring(0, b - 1);
}
return sub;
}

private void showMessage(String s) {
JOptionPane.showMessageDialog(null, s, "出错啦!",
JOptionPane.OK_OPTION);
}

private class InputClick implements ActionListener {

public void actionPerformed(ActionEvent e) {
if (e.getSource() == cancelbutton) {
dispose();
} else if (e.getSource() == okbutton) {
loading();
dispose();
}
}

}
}

private class FontDialog extends JFrame {
private JLabel fontLabel, fontStyle, fontSize;
private JComboBox fontName, fontStyleName, fontSizeName;
private JButton okButton, cancelButton;

public FontDialog() {
this.setTitle("字体");
init();
addItem();
this.setLayout(new FlowLayout());
this.add(fontLabel);
this.add(fontStyle);
this.add(fontSize);
this.add(fontName);
this.add(fontStyleName);
this.add(fontSizeName);
this.add(okButton);
this.add(cancelButton);
this.setSize(300, 150);
this.setLocation(Share.SCREENWIDTH / 4, Share.SCREENHEIGHT / 4);

}

private void init() {
fontLabel = new JLabel("字体");
fontStyle = new JLabel("字形");
fontSize = new JLabel("大小");
okButton = new JButton("OK");
cancelButton = new JButton("CANCEL");
fontName = new JComboBox();
fontStyleName = new JComboBox();
fontSizeName = new JComboBox();

}

private void addItem() {
// 字体列表
int[] stylename = { Font.BOLD, Font.CENTER_BASELINE,
Font.HANGING_BASELINE, Font.ITALIC,
Font.LAYOUT_LEFT_TO_RIGHT, Font.LAYOUT_LEFT_TO_RIGHT,
Font.LAYOUT_NO_LIMIT_CONTEXT, Font.LAYOUT_NO_START_CONTEXT,
Font.LAYOUT_RIGHT_TO_LEFT, Font.PLAIN, Font.ROMAN_BASELINE,
Font.TRUETYPE_FONT, Font.TYPE1_FONT };
String[] fontname = Toolkit.getDefaultToolkit().getFontList();
for (int i = 0; i < stylename.length; i++) {
fontStyleName.addItem(stylename[i]);
}
for (int i = 0; i < fontname.length; i++) {
fontName.addItem(fontname[i]);
}
for (int i = 0; i < 72; i++) {
fontSizeName.addItem(i);
}
}

public String getName() {
return fontName.getSelectedItem().toString();
}

public int getStyleName() {
return Integer.parseInt(fontStyleName.getSelectedItem().toString());
}

public int getFontSize() {
return Integer.parseInt(fontSizeName.getSelectedItem().toString());
}
}
}

分享到:
评论

相关推荐

    很强大的java反编译程序

    标题提到的“很强大的java反编译程序”通常指的是能够高效且方便地完成这一任务的工具。描述中提到的“jd-gui.exe”就是一款这样的工具,它是一款图形用户界面(GUI)的Java反编译器。 JD-GUI是一款免费且开源的...

    java反编译程序java反编译程序

    Java反编译程序是开发者和逆向工程人员用于查看Java字节码的工具,它能够将已编译的.class文件转换回源代码形式。在Java中,编译后的类文件包含的是字节码,这是一种中间表示,不同于人类可读的源代码。然而,通过反...

    java 反编译程序集合

    在这个“java反编译程序集合”中,包含了两种知名的反编译工具:Jode和Xjad。 1. **Jode**: Jode(Java Open Decoder)是一款开源的Java反编译器。它不仅仅是一个反编译工具,还包括了一个完整的JVM模拟器和一个类...

    java反编译程序XJad

    Java反编译程序,如XJad,是用于将已编译的Java字节码转换回源代码的工具。在Java编程中,源代码被编译成字节码,这是一种平台无关的中间语言,由Java虚拟机(JVM)执行。然而,出于各种原因,有时我们可能需要查看...

    超简单java反编译程序

    "超简单java反编译程序"是一个方便的小工具,使得这个过程变得极其简单。用户只需将Java源码文件拖放到exe程序上,就可以直接进行反编译,无需额外安装任何软件,体现了其便捷性。 在Java生态系统中,反编译工具有...

    java反编译程序,国际大奖

    "java反编译程序,国际大奖"这个标题暗示了我们讨论的是一个在国际上获得认可的优秀Java反编译工具。这类工具通常具有高效、准确地将字节码转换为可读性强的源代码的能力,这对于开发者调试、学习开源库或者分析恶意...

    jadnt158-JAVA反编译程序2015

    JAVA反编译程序是开发人员在处理已编译的Java类文件时不可或缺的工具,它可以帮助我们查看并理解无法直接获取的源代码。"jadnt158"是一款专为JAVA开发者设计的反编译软件,它允许用户查看多个jar包中的源码,并且...

    java反编译程序.rar

    在提供的压缩包“java反编译程序.rar”中,包含了一个名为“java反编译程序.exe”的可执行文件,这很可能是JD-GUI的安装程序或便携版。另一个文件“说明.docx”可能是关于如何使用JD-GUI的指南,包含了操作步骤和...

    java反编译程序,与eclipse集成

    除了JD-Eclipse,还有其他一些Java反编译工具,如JD-GUI,这是一个独立的应用程序,可以单独使用,或者与Eclipse集成。另一款著名的是Procyon,它不仅提供反编译功能,还包括了编译器和Java文档生成器。这些工具各有...

    JAVA反编译程序xjad2.0

    JAVA反编译程序是开发和调试Java应用程序时的有力工具,它们可以将已编译的.class文件转换回可读的源代码,这对于理解第三方库的工作原理、修复bug或学习已有的二进制代码非常有用。XJad是早期的Java反编译器之一,...

    反编译Java程序

    综合以上信息,这本《反编译Java程序》的书籍适合已经有一定Java基础的读者,通过学习书中提供的实际Java Applet程序设计的范例,可以提高对Java程序的理解和设计能力。同时,书籍也提醒读者在使用资源时要注意版权...

    java反编译工具绿色版

    Java反编译工具是程序员在开发和调试过程中经常会用到的一种实用软件,它能够将已编译的Java字节码(.class文件)转换回源代码格式,这对于查看和理解第三方库或者研究已有的二进制代码非常有帮助。本绿色版的Java反...

    java反编译工具

    Java反编译工具是开发者在特定情况下非常有用的工具,它能够将已经编译好的.class文件转换回源代码的.java文件。这种技术对于软件维护、学习他人代码、逆向工程或者理解已有的二进制库的工作原理都至关重要。本文将...

    java反编译程序jad-gui

    Java反编译是将已编译的Java字节码转换回源代码的过程,这对于学习开源项目的实现、逆向工程或调试二进制类文件非常有用。Jad-GUI是一款流行的Java反编译工具,它提供了图形用户界面,使得操作更为直观和简便。 Jad...

Global site tag (gtag.js) - Google Analytics