I have a simple maven project where I have a simple class analyzing File encoding. I am using the juniversalchardet library from Google juniversalchardet library . In the pom.xml I added the dependency from link above. When I build the project with mvn clean install, everything looks fine. In the local repository I see tha universalchardet.jar file also. The class file in my project is also compiled without errors. But when I run my project.JAR i get an error like this:
Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/universalchardet/UniversalDetector
Here is my dependency:
<dependency>
<groupId>com.googlecode.juniversalchardet</groupId>
<artifactId>juniversalchardet</artifactId>
<version>1.0.3</version>
</dependency>
I am not very familiar with Java - what I am doing wrong?
You can try this https://docs.oracle.com/javase/tutorial/deployment/jar/downman.html where you mention your dependency jar in your manifest file: Class-Path: juniversalchardet.jar
Or Consider making your jar as uber jar, refer: What is an uber jar?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.