문제

Structure of files in my jar is:

com/my/Main.class
META-INF/MANIFEST.MF
RXTXcomm.jar

Manifest.mf consist:

Manifest-Version: 1.0
Main-Class: com.my.Main
Class-Path: RXTXcomm.jar

(empty line present)

When I run my jar as: java -jar my.jar

I get: Exception in thread "main" java.lang.NoClassDefFoundError: gnu/io/SerialPortEventListener

What is wrong?

도움이 되었습니까?

해결책

What is wrong?

You have packaged the jar dependency inside your main jar. The intention of Class-Path is to add an external jar to the classpath, with the path relative to the location of the main jar.

Packaging a jar within a jar is not supported by standard Java classloaders. If you want, you can explode the inner jar into the main jar, though. Maven can do this for you.

다른 팁

The RXTXcomm.jar must not be inside the jar file, but outside of it. Read the tutorial.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top