java.lang.NoClassDefFoundError: com/ibm/icu/text/BreakIterator

本文介绍了一种在Eclipse RCP应用中使用StyledText组件时遇到的NoClassDefFoundError异常,并提供了解决方案,即禁用双击功能。

关键字:java.lang.NoClassDefFoundError: com/ibm/icu/text/BreakIterator StyledText

 

在RCP程序中使用StyledText的时候,发现了一个奇怪的错误总是报这个:

错误信息: 写道
!ENTRY org.eclipse.ui 4 0 2010-11-25 14:04:50.355
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NoClassDefFoundError: com/ibm/icu/text/BreakIterator
at org.eclipse.jface.text.DefaultTextDoubleClickStrategy.doubleClicked(DefaultTextDoubleClickStrategy.java:198)
at org.eclipse.jface.text.TextViewer$TextDoubleClickStrategyConnector.getPreviousOffset(TextViewer.java:216)
at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swt.custom.StyledText.sendWordBoundaryEvent(StyledText.java:8081)
at org.eclipse.swt.custom.StyledText.getWordPrevious(StyledText.java:5391)
at org.eclipse.swt.custom.StyledText.getWordPrevious(StyledText.java:5365)
at org.eclipse.swt.custom.StyledText.handleMouseDown(StyledText.java:6033)
at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5658)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at cn.udt.gui.app.Application.start(Application.java:37)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

 

 

结果在程序中加了:

styledText.setDoubleClickEnabled(false);

 

就没有错误了,不是太明白。

 

maybe should add plugin "com.ibm.icu"

`java.lang.NoClassDefFoundError: com/alibaba/fastjson/JSONArray` 是 Java 应用中常见的错误之一,表示 **JVM 在运行时找到 `com.alibaba.fastjson.JSONArray` 这个类**。 ### 原因分析: 1. **缺少 FastJSON 依赖** 项目中没有正确引入 `fastjson` 的 jar 包。 2. **依赖版本冲突或被排除** 在 Maven 或 Gradle 项目中,fastjson 被其他依赖项排除或版本冲突。 3. **依赖未正确打包进应用** 构建项目时(如生成 jar 包),fastjson 没有被打包进去。 4. **类路径(classpath)配置错误** 手动添加的 jar 包未正确配置到 classpath 中。 --- ### 解决方案: #### ✅ 1. Maven 项目:添加 FastJSON 依赖 在 `pom.xml` 中添加 fastjson 依赖(以最新稳定版为例): ```xml <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.83</version> </dependency> ``` #### ✅ 2. Gradle 项目: ```groovy implementation 'com.alibaba:fastjson:1.2.83' ``` #### ✅ 3. 手动导入 jar 包(非 Maven 项目) - 下载 fastjson jar 包:https://mvnrepository.com/artifact/com.alibaba/fastjson - 放入项目 lib 目录,并添加到构建路径(Build Path)或 classpath。 #### ✅ 4. 确保依赖被打包进最终 jar 如果你使用 Maven 构建可执行 jar,确保使用 `maven-assembly-plugin` 或 `maven-shade-plugin` 将依赖打包进去。 例如使用 `maven-assembly-plugin`: ```xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>com.example.MainClass</mainClass> </manifest> </archive> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> ``` 然后使用: ```bash mvn clean package ``` 生成的 jar 文件在 `target/xxx-jar-with-dependencies.jar` --- ### 示例代码(验证是否修复): ```java import com.alibaba.fastjson.JSONArray; public class TestFastJSON { public static void main(String[] args) { JSONArray array = new JSONArray(); array.add("test"); System.out.println(array.toJSONString()); } } ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值