Having problems using 3rd party java library, NoClassDefFoundError. Why do import commands matter?
이전 댓글 표시
I am working to get grpc-java to work in matlab. I have all the jar files I need in a directory, and to verify I was able to use javac to build and run an appication using this directory. The problem I have is if I try to run one of the grpc-java examples within matlab I get various NoSuchMethodError, or NoClassDefFoundError. What is interesting is I can get around the first NoSuchMethodError by adding an extra 'import io.grpc.ManagedChannelProvider' that is not part of the original example. But in the end I still get the error below. So my 2 questions are, 1) How can I figure out what is wrong here? 2) Why would I have to add an 'import' command if everything builds/runs fine on command line? But if this is the case, I guess my error would be fixed by adding another 'import' command, but how to figure out which one?
https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java
>> o = ManagedChannelBuilder.forAddress('localhost', 5001)
Java exception occurred:
java.lang.NoClassDefFoundError: Could not initialize class io.grpc.netty.NettyChannelBuilder
at io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:37)
at io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:23)
at io.grpc.ManagedChannelBuilder.forAddress(ManagedChannelBuilder.java:37)
채택된 답변
추가 답변 (1개)
Mohan Feng
2019년 1월 14일
0 개 추천
A possible reason of this issue is that you did not add all JAR files into MALTAB JAVA class path. You could refer to the answer in the following link to try to add all JAR files into static or dynamic MATLAB JAVA class path.
카테고리
도움말 센터 및 File Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!