在一些中文Linux系统上(比如:Ubuntu 8.04等)使用J2ME来开发手机移动应用的情况下,很多人都遇到了无法启动WTK及其模拟器的情况,在网络上搜索也难得到解决方案,通常大家在通过Eclipse启动Emulator的时候遇到的异常情况如下:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initSystemColorDefaults(GTKLookAndFeel.java:1267)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1509)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.access$000(GTKLookAndFeel.java:37)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel$WeakPCL$1.run(GTKLookAndFeel.java:1449)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
如果通过命令行直接启动WTK会遇到如下情况:
(<unknown>:14996): Gtk-WARNING **: Attempting to add a widget with type GtkButton to a GtkComboBoxEntry (need an instance of GtkEntry or of a subclass)
(<unknown>:14996): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(<unknown>:14996): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed
(<unknown>:14996): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed
这些错误是应用WTK及其模拟器采用了Java中的 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());语句来使用系统自身的lookandfeel,而Ubuntu系统中没有安装对应的主题导致的错误,而目前本人并没有在安装包中找到相关的主题安装内容(注意:不代表不存在,只是本人没有找到而已),如果有哪位同行找到也请发布上来,谢谢。
在当前情况下如何解决这一个问题是关键,这里本人给出了如下解决办法:
首先找到你的WTK的安装目录,在bin中找到ktoolbar和emulator这两个文件,这两个是启动WTK和Emulator的两个启动文件,使用vi或者gedit来对这两个文件进行编辑,在两个文件中的相关位置添加如下一行即可:
-Dswing.systemlaf="javax.swing.plaf.metal.MetalLookAndFeel" /
添加后的ktoolbar如下(注意红色标注的那行即可):
#
!/
bin
/
sh
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
javapathtowtk
=/
usr
/
java
/
jdk1.
6
.0_05
/
bin
/
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
PRG
=
$
0
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
# Resolve soft links
while
[
-
h
"
$PRG
"
];
do
ls
=
`
/
bin
/
ls
-
ld
"
$PRG
"
`
link
=
`
/
usr
/
bin
/
expr
"
$ls
"
:
'
.*-> (.*)$
'
`
if
/
usr
/
bin
/
expr
"
$link
"
:
'
^/
'
>
/
dev
/
null
2
>&
1
; then
PRG
=
"
$link
"
else
PRG
=
"
`/usr/bin/dirname $PRG`/$link
"
fi
done
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
KVEM_BIN
=
`dirname $PRG`
KVEM_HOME
=
`cd $
{KVEM_BIN}
/
.. ; pwd`
KVEM_LIB
=
"
${KVEM_HOME}/wtklib
"
KVEM_API
=
"
${KVEM_HOME}/lib
"
export MMAPI_GM_SOUNDBANK
=
"
${KVEM_API}/soundbank.dls
"
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
"
${javapathtowtk}java
"
-
Dkvem.home
=
"
${KVEM_HOME}
"
/
-
Djava.library.path
=
"
${KVEM_HOME}/bin
"
/
-Dswing.systemlaf="javax.swing.plaf.metal.MetalLookAndFeel"
/
-
cp
"
${KVEM_LIB}/kenv.zip:${KVEM_LIB}/ktools.zip:${KVEM_BIN}/JadTool.jar:${KVEM_BIN}/MEKeyTool.jar:${KVEM_LIB}/customjmf.jar:${KVEM_API}/j2me-ws.jar:${KVEM_BIN}/schema2beansdev.jar:${KVEM_BIN}/j2me_sg_ri.jar:${KVEM_BIN}/jaxrpc-impl.jar:${KVEM_BIN}/jaxrpc-api.jar:${KVEM_BIN}/jaxrpc-spi.jar:${KVEM_BIN}/activation.jar:${KVEM_BIN}/mail.jar:${KVEM_BIN}/saaj-api.jar:${KVEM_BIN}/saaj-impl.jar:${KVEM_BIN}/xsdlib.jar:${KVEM_LIB}/nist-sip-1.2.jar:${KVEM_LIB}/JainSipApi1.1.jar:${KVEM_LIB}/jain-sip-presence-proxy.jar
"
com.sun.kvem.toolbar.Main
"
$@
"
修改后的emulator文件内容如下:
#
!/
bin
/
sh
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
javapathtowtk
=/
usr
/
java
/
jdk1.
6
.0_05
/
bin
/
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
PRG
=
$
0
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
# Resolve soft links
while
[
-
h
"
$PRG
"
];
do
ls
=
`
/
bin
/
ls
-
ld
"
$PRG
"
`
link
=
`
/
usr
/
bin
/
expr
"
$ls
"
:
'
.*-> (.*)$
'
`
if
/
usr
/
bin
/
expr
"
$link
"
:
'
^/
'
>
/
dev
/
null
2
>&
1
; then
PRG
=
"
$link
"
else
PRG
=
"
`/usr/bin/dirname $PRG`/$link
"
fi
done
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
KVEM_BIN
=
`dirname
"
$PRG
"
`
KVEM_HOME
=
`cd
"
${KVEM_BIN}/..
"
; pwd`
KVEM_LIB
=
"
${KVEM_HOME}/wtklib
"
export MMAPI_GM_SOUNDBANK
=
"
${KVEM_HOME}/lib/soundbank.dls
"
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
"
${javapathtowtk}java
"
-
Dkvem.home
=
"
${KVEM_HOME}
"
/
-
Djava.library.path
=
"
${KVEM_HOME}/bin
"
/
-Dswing.systemlaf="javax.swing.plaf.metal.MetalLookAndFeel"
/
-
cp
"
${KVEM_LIB}/kenv.zip:${KVEM_LIB}/ktools.zip:${KVEM_LIB}/customjmf.jar
"
com.sun.kvem.environment.EmulatorWrapper
"
$@
"
0
好了,大功告成,现在可以运行WTK和Emulator了,而且还是中文的,继续努力吧。。。。。。
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initSystemColorDefaults(GTKLookAndFeel.java:1267)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1509)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.access$000(GTKLookAndFeel.java:37)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel$WeakPCL$1.run(GTKLookAndFeel.java:1449)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
如果通过命令行直接启动WTK会遇到如下情况:
(<unknown>:14996): Gtk-WARNING **: Attempting to add a widget with type GtkButton to a GtkComboBoxEntry (need an instance of GtkEntry or of a subclass)
(<unknown>:14996): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(<unknown>:14996): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed
(<unknown>:14996): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed
这些错误是应用WTK及其模拟器采用了Java中的 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());语句来使用系统自身的lookandfeel,而Ubuntu系统中没有安装对应的主题导致的错误,而目前本人并没有在安装包中找到相关的主题安装内容(注意:不代表不存在,只是本人没有找到而已),如果有哪位同行找到也请发布上来,谢谢。
在当前情况下如何解决这一个问题是关键,这里本人给出了如下解决办法:
首先找到你的WTK的安装目录,在bin中找到ktoolbar和emulator这两个文件,这两个是启动WTK和Emulator的两个启动文件,使用vi或者gedit来对这两个文件进行编辑,在两个文件中的相关位置添加如下一行即可:
-Dswing.systemlaf="javax.swing.plaf.metal.MetalLookAndFeel" /
添加后的ktoolbar如下(注意红色标注的那行即可):
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
修改后的emulator文件内容如下:
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
好了,大功告成,现在可以运行WTK和Emulator了,而且还是中文的,继续努力吧。。。。。。