eclipse使用LWUIT时报错java.lang.NoClassDefFoundError解决方法

简介: 本人的环境:eclipse3.3+eclipseme1.7.9+wtk2.5 测试源程序: import com.sun.lwuit.Display; import com.sun.lwuit.Form; import com.sun.lwuit.Label; import com.sun.lwuit.layouts.BorderLayout; import com.sun.lwu

本人的环境:eclipse3.3+eclipseme1.7.9+wtk2.5

测试源程序:

import com.sun.lwuit.Display;

import com.sun.lwuit.Form;

import com.sun.lwuit.Label;

import com.sun.lwuit.layouts.BorderLayout;

import com.sun.lwuit.plaf.UIManager;

import com.sun.lwuit.util.Resources;

 

public class Test extends javax.microedition.midlet.MIDlet {

   public void startApp() {

      // init the LWUIT Display

      Display.init(this);

      // Setting the application theme is discussed

      // later in the theme chapter and the resources chapter

     

      Form f = new Form();

      f.setTitle("Hello World");

      f.setLayout(new BorderLayout());

      f.addComponent("Center", new Label("I am a Label"));

      f.show();

   }

 

   public void pauseApp() {

   }

 

   public void destroyApp(boolean unconditional) {

   }

}

报错图如图1所示下:

1报错截图

 

解决方法:如图2所示

右击项目选择Properties->Java Build Path在右面的窗口中选择Order and Export, 点击Select All,选中里面的文件。

2 解决方法

程序运行成功的截图如图3所示:

  

3  程序运行成功

 

 

网上搜出来的解决方法2(经本人测试不行),在这里也写出来下:

order and export选卡旁边有Libraries       

       展开 LWUIT.jar           

       设置source attachment(双击即可设置)             

设置native library location

如果没有在order and export中全选,程序运行时也会报同样的错误。

还有就是经过网友测试,eclipse版本为3.4时测试不通过,程序通过以上设置后也会报同样的错误。

order and export作用:选择你要生成的或用来发布的类和文件从哪里取出来,一般默认就可以,但假如你有多个工程,或者有多个文件夹,这时你就需要选择!!!

问题产生原因

在设置eclispeme时:默认情况下 "source and outpub folder"项的 "project"为选中,我们修改这个默认设置,把"folders"选中

这样,就可以让eclipse把源代码和输出分离开。再看下order and export作用就应该明白了。

@@@@@@还有就是经过网友测试,eclipse版本为3.4时测试不通过,程序通过以上设置后也会报同样的错误。

最后,在项目打成JAR包时,要将LWUIT.jar文件一起打包,并且更改JAD文件,才能运行,这里就不在写了。

有问题请指正  QQ:250753635

 

 

目录
相关文章
|
4月前
|
Java UED
Java中String强转int:一种常见的错误和解决方法
在Java中将非数字字符串转换为整数会导致`NumberFormatException`。要解决这个问题,可以使用`try-catch`捕获异常,正则表达式验证数字格式,或利用异常信息提供错误提示。例如,`Integer.parseInt()`会因遇到非数字字符如`"123abc"`而抛出异常,但通过异常处理或正则`\\d+`可确保安全转换。记得在编程时避免直接强转,以防止程序异常中断。
|
5月前
|
Java Android开发
在Eclipse环境下调试Java程序
在Eclipse环境下调试Java程序
66 1
|
1月前
|
Oracle Java 关系型数据库
Java(TM) Platform SE binary 已停止工作”的解决方法
Java(TM) Platform SE binary 已停止工作”的解决方法
134 2
|
2月前
|
开发工具
java.lang.unsatisfiedlinkerror解决方法
java.lang.unsatisfiedlinkerror解决方法
243 1
|
5月前
|
Java 应用服务中间件 Spring
SpringBoot出现 java.lang.IllegalArgumentException: Request header is too large 解决方法
SpringBoot出现 java.lang.IllegalArgumentException: Request header is too large 解决方法
224 0
|
4月前
|
缓存 监控 算法
【Java】Java内存溢出:原因、预防和解决方法
【Java】Java内存溢出:原因、预防和解决方法
592 2
|
3月前
|
Java
idea启动java服务报错OutOfMemoryError: GC overhead limit exceeded解决方法
idea启动java服务报错OutOfMemoryError: GC overhead limit exceeded解决方法
727 0
|
3月前
|
存储 Oracle Java
Java面试题:描述如何使用Eclipse或IntelliJ IDEA进行Java开发?
Java面试题:描述如何使用Eclipse或IntelliJ IDEA进行Java开发?
44 0
|
3月前
|
关系型数据库 MySQL 数据库连接
解决在eclipse2021中,用mysql-connector-java-8.0.18.jar不兼容,导致无法访问数据库问题
解决在eclipse2021中,用mysql-connector-java-8.0.18.jar不兼容,导致无法访问数据库问题
80 0
|
3月前
|
存储 监控 算法
Java中的内存泄漏问题及其解决方法
Java中的内存泄漏问题及其解决方法

推荐镜像

更多