ubuntu8.04 j2me环境搭建问题

解决答案转自:http://blog.csdn.net/killua_hzl/archive/2008/11/13/3293182.aspx

不知道什么原因,我想在ubuntu上搭建j2me开发环境 eclipse sdk 3.3.1+eclipseme1.7.9+wtk2.5.2,然后创建一个j2me项目,就报一下错误:
然后试着降低版本: eclipse sdk 3.3.1 + eclipseme 1.7.7 + wtk2..5.1,还是以失败告终,错误好像一样,不知道为什么,希望大家帮我分析一下(jdk是1.6)


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)
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)
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.kvem.environment.EmulatorInvoker.runEmulatorImpl(Unknown Source)
at com.sun.kvem.environment.EmulatorInvoker.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.kvem.environment.JVM.main(Unknown Source)
Caused by: java.lang.NullPointerException
at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:117)
at javax.swing.UIDefaults.getUI(UIDefaults.java:741)
at javax.swing.UIManager.getUI(UIManager.java:1012)
at javax.swing.JMenuItem.updateUI(JMenuItem.java:232)
at javax.swing.JMenuItem.init(JMenuItem.java:194)
at javax.swing.JMenuItem.<init>(JMenuItem.java:133)
at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:147)
at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:87)
at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:115)
at com.sun.kvem.midp.MIDP.initMenuActions(Unknown Source)
at com.sun.kvem.midp.MIDP.<clinit>(Unknown Source)
... 11 more




最后终于找到解决办法:
http://blog.csdn.net/killua_hzl/archive/2008/11/13/3293182.aspx

(关于如何安装,这里不再叙述,很简单。eclipse sdk 3.4版本安装插件方式和3.4以前的版本稍微有些不同,自己捣鼓一下就OK了。)
我现在的环境
  eclipse-SDK-3.4.2-linux-gtk 、 eclipseme.feature_1.7.9_site.zip、 sun_java_wireless_toolkit-2_5_2-ml-linux.bin

解决办法:
    首先找到你的WTK的安装目录,在bin中找到ktoolbar和emulator这两个文件,这两个是启动WTK和Emulator的两个启动文件,使用vi或者gedit来对这两个文件进行编辑,在两个文件中的相关位置添加如下一行即可:
   -Dswing.systemlaf="javax.swing.plaf.metal.MetalLookAndFeel" \
    添加后的ktoolbar如下(注意红色标注的那行即可):
#!/bin/sh

javapathtowtk=/usr/java/jdk1.6.0_05/bin/

PRG=$0

# 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

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"

"${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

javapathtowtk=/usr/java/jdk1.6.0_05/bin/

PRG=$0

# 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

KVEM_BIN=`dirname "$PRG"`
KVEM_HOME=`cd "${KVEM_BIN}/.." ; pwd`
KVEM_LIB="${KVEM_HOME}/wtklib"
export MMAPI_GM_SOUNDBANK="${KVEM_HOME}/lib/soundbank.dls"

"${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

你可能感兴趣的:(java,eclipse,linux,swing,sun)