Possible Duplicate:
You must include the platform port before the LWUIT in the classpath runtime exception
我刚刚开始在J2ME中使用LWUIT。我对LWUIT的了解不多,但是我对J2ME有更好的了解。我在我的J2ME项目中添加了LWUIT库,它的编译很好,但是在运行时它显示以下异常:
java.lang.RuntimeException: You must include the platform port before the LWUIT in the classpath
at com.sun.lwuit.impl.ImplementationFactory.createImplementation(ImplementationFactory.java:67)
at com.sun.lwuit.Display.init(Display.java:406)
at HelloMidlet.<init>(HelloMidlet.java:26)
at java.lang.Class.newInstance(), bci=0
at com.sun.midp.main.CldcMIDletLoader.newInstance(), bci=46
at com.sun.midp.midlet.MIDletStateHandler.createMIDlet(), bci=66
at com.sun.midp.midlet.MIDletStateHandler.createAndRegisterMIDlet(), bci=17
at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=27
at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
import com.sun.lwuit.*;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.animations.Transition3D;
import com.sun.lwuit.events.*;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
import java.io.IOException;
public class HelloMidlet extends MIDlet implements ActionListener {
private Form form1;
private Form form2;
private Command cmdRotate = new Command("Rotate");
private Command cmdSlide = new Command("Slide");
private Command cmdExit = new Command("Exit");
public HelloMidlet(){
Display.init(this);
}
public void startApp() {
Resources r;
try{
r=Resources.open("/TimelineTheme.res");
UIManager.getInstance().setThemeProps(r.getTheme("LWUITDefault"));
}catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}
form1 = new Form("Form 1");
form1.setLayout(new BorderLayout());
form1.addComponent(BorderLayout.NORTH, new Label("My First Form"));
form1.addComponent(BorderLayout.WEST, new Label("WEST"));
form1.addComponent(BorderLayout.CENTER, new Label("CENTER"));
form1.addComponent(BorderLayout.EAST, new Label("EAST"));
form1.addComponent(BorderLayout.SOUTH, new Label("Click Rotate"));
form1.addCommand(cmdRotate);
form1.addCommand(cmdExit);
form1.addCommandListener(this);
form1.setTransitionInAnimator(CommonTransitions.createSlide(
CommonTransitions.SLIDE_HORIZONTAL, true, 1000));
//Setup Form 2
form2 = new Form("Form 2");
form2.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
form2.addComponent(0,null,new Label("This is the second Form"));
form2.addCommand(cmdSlide);
form2.addCommand(cmdExit);
form2.addCommandListener(this);
form2.setTransitionInAnimator(Transition3D.createCube(1000, true));
form1.show();
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void actionPerformed(ActionEvent ae) {
if (ae.getCommand()==cmdExit) {
notifyDestroyed();
} else if (ae.getCommand()==cmdRotate) {
form2.show();
} else if (ae.getCommand()==cmdSlide) {
form1.show();
}
}
}
最佳答案
你看到那个帖子了吗? You must include the platform port before the LWUIT in the classpath runtime exception
我认为这是一个类似的问题。尝试解决此问题,如上述问题的答案所示:
问题是我包含在UI jar中。 LWUIT随附2
“组”的UI.jar
。通用文件夹位于LWUIT \ UI文件夹中,
特定于平台的文件位于LWUIT \ Ports文件夹中。
一个被用作包含所有共同点的“父”项目
代码,但是如果您必须导入适合您的.jar文件
平台。如自述文件所述:
尽管这些项目可以轻松编译,但由于它们不包含用于开发的绑定(bind)胶,因此它们对任何目的都将毫无用处。
平台,要使用平台一个需要使用适当的平台
将特定端口目录下的项目映射到给定平台。
当我重新编译库以删除
我转换了Transitions3D.java文件(然后导入了)
UI.jar。正确的做法是编译,父项目(
通用UI.jar)然后编译端口特定的库(在我的情况下,
LWUIT \ ports \ MIDP \ UI.jar),然后将其导入项目中
完成。