(原創) 如何解決使用preverify時,出現『Segmentation fault』的錯誤訊息? (OS) (Linux) (CentOS) (Java) (J2ME) (MIDP)
Abstract
preverify主要的功能是將原本在J2SE編譯過的class,檢查是否能在MIDP裝置正常執行。但儘管是最簡單的HelloWorld.class,也會出現『Segmentation fault』錯誤。
Introduction
執行環境:CentOS 5.1 + J2SE 1.4.2.17 + J2ME CLDC 1.1 + μClinux 20070130
最簡單的HelloWorld,使用preverify就出現以下錯誤訊息。
[root@localhost uClinux]# ./preverify -classpath classes.zip -verbose HelloWorld
[Output directory for verified classes: output]
Segmentation fault
[Output directory for verified classes: output]
Segmentation fault
Solution
Step 1:
顯示你目前使用的語系
[root@localhost uClinux]# echo $LANG
en_US.UTF-8
en_US.UTF-8
無論你使用中文或英文,只要使用了UTF-8,就會出現這個錯誤訊息。
Step 2:
暫時改成其他語系
[root@localhost uClinux]# export LANG=en_US.ISO8859-1
[root@localhost uClinux]# echo $LANG
en_US.ISO8859-1
[root@localhost uClinux]# echo $LANG
en_US.ISO8859-1
Step 3:
順利執行preverify
[root@localhost uClinux]# ./preverify -classpath classes.zip -verbose HelloWorld
[Output directory for verified classes: output]
[Loaded java/lang/Object] from [classes.zip]
[Loaded java/lang/Class] from [classes.zip]
[Loaded java/lang/String] from [classes.zip]
[Loaded java/lang/Throwable] from [classes.zip]
[Loaded java/lang/IllegalArgumentException] from [classes.zip]
[Loaded java/lang/RuntimeException] from [classes.zip]
[Loaded java/lang/Exception] from [classes.zip]
[Loaded java/lang/StringIndexOutOfBoundsException] from [classes.zip]
[Loaded java/lang/IndexOutOfBoundsException] from [classes.zip]
[Loaded java/io/InputStream] from [classes.zip]
[Loaded com/sun/cldc/io/ResourceInputStream] from [classes.zip]
[Loaded ./HelloWorld.class]
[Output directory for verified classes: output]
[Loaded java/lang/Object] from [classes.zip]
[Loaded java/lang/Class] from [classes.zip]
[Loaded java/lang/String] from [classes.zip]
[Loaded java/lang/Throwable] from [classes.zip]
[Loaded java/lang/IllegalArgumentException] from [classes.zip]
[Loaded java/lang/RuntimeException] from [classes.zip]
[Loaded java/lang/Exception] from [classes.zip]
[Loaded java/lang/StringIndexOutOfBoundsException] from [classes.zip]
[Loaded java/lang/IndexOutOfBoundsException] from [classes.zip]
[Loaded java/io/InputStream] from [classes.zip]
[Loaded com/sun/cldc/io/ResourceInputStream] from [classes.zip]
[Loaded ./HelloWorld.class]