① 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對某些高版本的類無法解析,對於一些進行過位元組碼混淆的類也無法解析。