2013-10-22 50 views
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) 

我的代碼是:

​​
+0

序列化對象不存儲在文本文件中。所以不要給它一個'txt'名字結尾。否則,請確保您的文件傳輸程序不會像使用程序選項的文本文件那樣對待它。如果傳輸程序應用換行符和字符集編碼轉換,它們很可能會垃圾文件。 – Holger

+0

我測試過了。 WinSCP被設置爲自動文件傳輸。我手動切換到二進制模式ac_geonames_country_all.txt文件。文件大小已更改,但錯誤保持不變。 –

+0

您是如何創建該文件的,您正在序列化的對象的定義是什麼? – EJP

回答

0

我設法讓它工作。我直接在Linux服務器上重新創建文件。現在一切正常。在文件傳輸過程中出現問題。或者Java在Linux上以不同的方式序列化文件。我沒有任何線索。

@EJP感謝您指出了這一點。然後文件傳輸會弄亂文件。

+1

Java在Linux上不會序列化不同的文件。 – EJP

相關問題