安装Java jdk后
看安装目录里有没有jad.exe,没有要下载,一般都有的
配置Java环境变量
开始-运行-cmd-回车-进入命令行窗口:
cd+空格+class文件所在路径:
按下面的命令进行反编译:
例如:[2] jad -sjava example.class 回车
在目录里可以看到example.java源文件
[1] 反编译一个class文件:jad example.class,会生成example.jad,用文本编辑器打开就是java源代码
[2] 指定生成源代码的后缀名:jad -sjava example.class,生成example.java
[3] 改变生成的源代码的名称,可以先使用-p将反编译后的源代码输出到控制台窗口,然后使用重定向,输出到文件:jad -p example.class > myexample.java
[4] 把源代码文件输出到指定的目录:jad -dnewdir -sjava example.class,在newdir目录下生成example.java
[5] 把packages目录下的class文件全部反编译:jad -sjava packages/*.class
[6] 把packages目录以及子目录下的文件全部反编译:jad -sjava packages/**/*.class,不过你仍然会发现所有的源代码文件被放到了同一个文件中,没有按照class文件的包路径建立起路径
[7] 把packages目录以及子目录下的文件全部反编译并建立和java包一致的文件夹路径,可以使用-r命令:jad -r -sjava packages/**/*.class
[8] 当重复使用命令反编译时,Jad会提示“whether you want to overwrite it or not”,使用-o可以强制覆盖旧文件
[9] 还有其他的参数可以设置生成的源代码的格式,可以输入jad命令查看帮助,这里有个人做了简单的翻译:jad命令总结
[10] 当然,你会发现有些源文件头部有些注释信息,不用找了,jad没有参数可以去掉它,用别的办法吧。
⑵ 怎样用c++重定向一个可执行文件(linux下)
仅仅用execl是不可能的。可以尝试用system()函数。
execl的语法是*args是binary的输入参数。redirection “>" 和”<"不是binary的输入参数,而是linux shell的功能。
要用p2与execl一起。这里提供一个网上别人的例子:www.unix.com/programming/53220-execl-redirecting-output-text-files.html
错误用法:
execl( "/bin/ls" , "-al" , '>' , "dirlist.txt" ,(char *) 0 );
和你的差不多。
别人建议正确代码(我没有试过):
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char *argv)
{
int fd; /*file descriptor to the file we will redirect ls's output*/
if((fd = open("dirlist.txt", O_RDWR | O_CREAT))==-1){ /*open the file */
perror("open");
return 1;
}
p2(fd,STDOUT_FILENO); /* the file descriptor fd into standard output*/
p2(fd,STDERR_FILENO); /* same, for the standard error */
close(fd); /* close the file descriptor as we don't need it more */
/*execl ls */
execl( "/bin/ls" , "ls" , "-la" , (char *) 0 );
return 0;
}