0
我試圖在我的Linux服務器上運行一個jar文件。在我的Windows桌面,我可以就好使用命令來執行jar文件:java.io.StreamCorruptedException:無效的類型代碼:9D
java -Xss1000m -XX:-UseGCOverheadLimit -Xmx5048m -jar test.jar
然而,當我在我的Linux服務器上運行它,我得到以下錯誤:
java.io.StreamCorruptedException: invalid type code: 9D
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1374)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1988)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1795)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at com.test.test.Main.main(Main.java:41)
我的代碼是:
序列化對象不存儲在文本文件中。所以不要給它一個'txt'名字結尾。否則,請確保您的文件傳輸程序不會像使用程序選項的文本文件那樣對待它。如果傳輸程序應用換行符和字符集編碼轉換,它們很可能會垃圾文件。 – Holger
我測試過了。 WinSCP被設置爲自動文件傳輸。我手動切換到二進制模式ac_geonames_country_all.txt文件。文件大小已更改,但錯誤保持不變。 –
您是如何創建該文件的,您正在序列化的對象的定義是什麼? – EJP