① jd-gui反编译jar包代码是否能完全显示正确的问题
一般来说是可以的,但也有例外情况,如果代码使用了混淆,那你反编译的代码也是看不懂的。还有就是我遇见过文件不是别的情况。
② 用JD-eclipse反编译出现 throw new RuntimeException("Stub!")
javaDB其实就是Derby,它并不是一个新的数据库产品,它是由IBM捐献给Apache的DB项目的一个纯Java数据库,JDK6.0里面带的这个Derby的版本是 10.2.1.7,支持存储过程和触发器;有两种运行模式,一种是作为嵌入式数据库,另一种是作为网络数据库,前者的数据库服务器和客户端都在同一个 JVM里面运行,后者允许数据库服务器端和客户端不在同一个JVM里面,而且允许这两者在不同的物理机器上.值得注意的是JDK6里面的这个Derby支持JDK6的新特性JDBC 4.0规范(JSR 221),现在我们如果要练习JDBC的用法,没有必要单独装一个数据库产品了,直接用Derby就行.
1、本身没有操作界面,可以用第三方工具来管理(也就是你说的操作界面),Aqua Data Studio 具备管理功能的用于 Apache Derby 关系数据库的管理工具和数据库查询工具。直观管理功能让用户能够浏览和修改数据库结构,包括架构对象和数据库存储,以及维护数据库安全。集成查询工具让您能够迅速创建、编辑和执行 SQL 查询与脚本。Aqua Data Studio 进一步提供导入与导出工具,从而轻松地将数据移入和移出不同的数据格式及 Apache Derby 数据库。集成在这些工具内的是库浏览器 (Repository Browser),拥有 CVS 和 Subversion (SVN) 的完整来源控制客户端。
2、两者的区别,简单的说,就是javaDB是一个简化轻量级数据库,适合小型系统的小规模测试用,完全可以跑在内存里的数据库,它只有3M大小,而MySQL则是可以应用部署大型系统的数据库,功能更多更全,也更稳定,是用范围更广。
3、下面是个使用derby的简单例子:
首先导入JAR包:derby.jar,如果你装的是JDK6,在C:\Program Files\Sun\JavaDB\lib目录下就可以找到.
然后就要创建数据库了:
代码
private Connection getConnection() throws SQLException {
Connection connection = DriverManager
.getConnection("jdbc:derby:userDB;create=true;user=test;password=test");
connection.setAutoCommit(false);
return connection;
}
其中userDB是要连接数据库的名字,create=true表示如果该数据库不存在,则创建该数据库,如果数据库存在,则用用户user=test;密码password=test连接数据库.
有了数据库,接下来该建表了:
代码
private void createTable(Connection connection) throws SQLException {
Statement statement = connection.createStatement();
String sql = "create table USERS("
+ " ID BIGINT not null generated by default as identity,"
+ " USER_NAME VARCHAR(20) not null,"
+ " PASSWORD VARCHAR(20),"
+ " constraint P_KEY_1 primary key (ID))";
statement.execute(sql);
sql = "create unique index USER_NAME_INDEX on USERS ("
+ " USER_NAME ASC)";
statement.execute(sql);
statement.close();
}
创建了 USERS表,包括ID,USER_NAME,PASSWORD三个列,其中ID是主键,其中generated by default as identity 的作用类似sequence,identity是定义自动加一的列,
GENERATED BY ALWAYS AS IDENTITY
GENERATED BY DEFAULT AS IDENTITY
By always和by default是说明生成这个IDENTITY的方式。
By always是完全由系统自动生成。
by default是可以由用户来指定一个值。
编写与USERS表对应的javabean(这个就不多说了),:
代码
public class User implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Long id;
private String userName;
private String password;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
接下来就可以就数据库进行增删改查的操作了:
插入数据:
代码
private void create(User user) {
Connection connection = null;
try {
connection = this.getConnection();
PreparedStatement statement = connection
.prepareStatement("insert into users (user_name,password) values(?,?)");
int index = 1;
statement.setString(index++, user.getUserName());
statement.setString(index++, user.getPassword());
statement.execute();
user.setId(this.getId(connection));
connection.commit();
} catch (SQLException e) {
rollback(connection);
throw new RuntimeException(e);
} finally {
if (connection != null) {
close(connection);
}
}
}
代码
private Long getId(Connection connection) throws SQLException {
CallableStatement callableStatement = connection
.prepareCall("values identity_val_local()");
ResultSet resultSet = callableStatement.executeQuery();
resultSet.next();
Long id = resultSet.getLong(1);
resultSet.close();
callableStatement.close();
return id;
}
getId方法是获得系统默认的id值,是通过 identity_val_local()获得的,而函数IDENTITY_VAL_LOCAL()则可以在INSERT语句执行之后,为我们返回刚才系统为id所产生的值.感觉还是有点想sequence的curr_val.
修改数据:
代码
private void update(User user) {
Connection connection = null;
try {
connection = this.getConnection();
PreparedStatement statement = connection
.prepareStatement("update users set user_name=?,password=? where id=?");
int index = 1;
statement.setString(index++, user.getUserName());
statement.setString(index++, user.getPassword());
statement.setLong(index++, user.getId());
statement.execute();
connection.commit();
} catch (SQLException e) {
rollback(connection);
throw new RuntimeException(e);
} finally {
if (connection != null) {
close(connection);
}
}
}
删除数据:
代码
public void delete(Long id) {
Connection connection = null;
try {
connection = this.getConnection();
PreparedStatement statement = connection
.prepareStatement("delete from users where id=?");
statement.setLong(1, id);
statement.execute();
connection.commit();
} catch (SQLException e) {
rollback(connection);
throw new RuntimeException(e);
} finally {
if (connection != null) {
close(connection);
}
}
}
查询数据:
代码
public User findById(Long id) {
Connection connection = null;
try {
connection = this.getConnection();
PreparedStatement statement = connection
.prepareStatement("select user_name,password from users where id=?");
statement.setLong(1, id);
ResultSet resultSet = statement.executeQuery();
User user = null;
if (resultSet.next()) {
user = new User();
user.setId(id);
user.setUserName(resultSet.getString("user_name"));
user.setPassword(resultSet.getString("password"));
}
resultSet.close();
statement.close();
connection.commit();
return user;
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
close(connection);
}
}
}
③ eclipse编译出的.jar,使用jd-gui.exe反编译查看,出现中文乱码,怎么破
如果是下载了jd-gui软件,在help—preferences—勾选escape unicode characters就可以解决中文乱码问题
④ 我用jd-gui反编译class文件,通过javac编译,提示错误: 编码GBK的不可映射字符
运行控制台,程序->运行,输入CMD,点击确定进入DOS操作系统 快捷键windows键+R键
编写需要运行的java代码!
/**
*@authorjava
*@version创建时间:2014-11-7下午2:31:53
*类说明
*/
publicclasshelloword{
publicstaticvoidmain(String[]args){
System.out.println("hello中文字符,,,中文字符word");
System.out.println("hello中文字符,,,中文字符word");
System.out.println("hello中文字符,,,中文字符word");
System.out.println("hello中文字符,,,中文字符word");
System.out.println("hello中文字符,,,中文字符word");
System.out.println("hello中文字符,,,中文字符word");
System.out.println("hello中文字符,,,中文字符word");
System.out.println("hello中文字符,,,中文字符word");
System.out.println("hello中文字符,,,中文字符word");
}
}
3. 切换运行目录到您存放java代码的目录!使用命令 cd 切换
4. 常规执行命令javac helloword.java,出现如下错误!
5. 解决错误提示:编码 GBK 的不可映射字符,使用命令:javac -encoding utf-8 helloword.java,编译成功
6. 成功编译后,在tmp目录下能看到helloword.java文件编译后的.class字节码文件
7. 使用命令【java helloword】,运行java程序
⑤ 用jd-gui反编译jdk1.8中rt.jar包,有如下错误
jd-gui、小型软件、操作多文件时发生错误经常的。。。
rt.jar都有源码、使用winrar打开查看即可。。。
eclipse可以调用,直接书写代码即可查看。。。
⑥ ECLIPSE安装JD-ECLIPSE反编译插件问题
安装 visual studio 2008 redistributable package 貌似JD-ECLIPSE是用(至少一部分)C++写的,如果你的电脑上没有装VC9,那就安装上面说的那个东西地址: http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en
⑦ 问个反编译问题:先用Androd反编译工具将APK反编译成JAR,但是jd-gui打不开JAR啊
有的可以打开,有的不可以,取决于操作系统版本,上次我有个在WIN7下打不开,在XP下就能打开
⑧ 谁有办法把class文件反编译为java吗,不能出任何错误。我用jd总是有错误,而且好像有层级限制
jd只是适合少量class文件,如果太多的话,类的引用就太繁琐了,偶尔会出错。我也是用XJAD反编译的,它可以反编译一个jar包。反编译有啥原理呢?虚拟机将*.java文件编译成字节码(*.class文件)然后,在编译成本地机器码,执行;我们一般用来传播的也就是*.class文件,这是一种有标准格式的字节码,开发工具按这个格式在将转换为*.java程序,就这样咯。而且,如果你要学了*.class文件的结构,自己都能计算出对应的*.java文件,只不过很复杂,很繁琐。
⑨ 请问jd-gui-windows-1.4.0这个java反编译程序打不开文件是怎么回事
你可以尝试,你任何项目下面的WEB-INF下面的classes下面的文件试试,排除你这个文件引用了特殊的jar包,又恰巧你这里没有完整的环境
⑩ 使用jd-gui出现如图情况一部分Java,一部分smali,是怎么回事。望大神指点
jd-gui对某些高版本的类无法解析,对于一些进行过字节码混淆的类也无法解析。