您必须在类路径中的 LWUIT 之前包含平台端口:如何解决此运行时异常?

发布于 2025-01-04 22:23:07 字数 3852 浏览 1 评论 0原文

可能的重复:
您必须包含类路径运行时异常中LWUIT之前的平台端口

我现在刚刚开始在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();
        }
  }
}

Possible Duplicate:
You must include the platform port before the LWUIT in the classpath runtime exception

I am just now started the LWUIT use in J2ME. I don't have more knowledge of LWUIT but I know better J2ME. I have added library of LWUIT in my J2ME project, it's compiling fine but at run time it is showing below exception:

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

How to solve this problem?

Below is my code:

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();
        }
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无语# 2025-01-11 22:23:07

你看到那个帖子了吗? 您必须包含类路径运行时异常中的LWUIT之前的平台端口

我认为这是一个类似的问题。尝试解决它,如上面问题的答案中所建议的:

问题是在我包含的 UI jar 中。 LWUIT 附带 2
UI.jar 的“集”。通用的位于 LWUIT\UI 文件夹中,
平台特定的位于 LWUIT\Ports 文件夹中。通用
一个被用作包含所有常见内容的“父”项目
代码,但是如果您必须导入适合您的 .jar 文件
平台。正如自述文件所述:

<块引用>

虽然这些项目很容易编译,但它们对于任何目的都是无用的,因为它们不包含用于
平台,要使用该平台需要使用适当的
特定 ports 目录下的项目到给定平台。

当我重新编译库以删除
Transitions3D.java 文件,我重新编译(然后导入)通用的
UI.jar。正确的做法是编译,父项目(
generic UI.jar)然后编译端口特定的库(在我的例子中
LWUIT\ports\MIDP\UI.jar) 然后将其导入到您的项目中
完成了。

Did you see that post? You must include the platform port before the LWUIT in the classpath runtime exception

I think that this is a similar problem. Try to solve it, as suggested in the answer in above question:

The problem was that in the UI jar I was including. LWUIT comes with 2
"sets" of UI.jar. The generic one which is in LWUIT\UI folder and the
platform specific ones which are in the LWUIT\Ports folder.The generic
one is being used as "parent" project containing all the common
code,however if you MUST import the .jar file which is for your
platform. As readme file says:

While these projects will compile easily they will be useless for any purpose since they don't include the binding glue for the
platform, to use the platform one needs to use the appropriate
projects underneath the specific ports directory to a given platform.

While I was recompiling the library in order to remove
Transitions3D.java file, I recompiled (and then imported ) the generic
UI.jar. The correct thing to do is compile, the parent project (the
generic UI.jar) THEN compile the port specific library (in my case the
LWUIT\ports\MIDP\UI.jar) and then import it in your project and you
are done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文