Matlab cannot see some of my java classes (not all) in jar package

后端 未结 6 1239
不思量自难忘°
不思量自难忘° 2021-01-02 04:19

I have a problem that is driving me nuts. Matlab sees only some of my classes embeded in a JAR file

If I compile the classes outside of a package and add the path to

6条回答
  •  清歌不尽
    2021-01-02 05:02

    One more reason why this is happening is the need of some classes to be in the static classpath of Matlab.

    In this case, one of my java classes worked perfectly in Matlab2017b after adding more jars to the dynamic classpath via javaaddpath as suggested above. That prevented the java.lang.ClassNotFoundException from happening.

    The same approach failed in Matlab2019a.

    Now I figured that my problem is solved by simply adding my 'uber' jar containing all the jars my application needs to the classpath.txt file, like so:

       # DO NOT MODIFY THIS FILE.  IT IS AN AUTOGENERATED FILE.
    
    /Users/andyhueni/Desktop/SPECCHIO_new_build2/SPECCHIO.app/Contents/Java/specchio-client.jar
    
    $matlabroot/java/patch
    $matlabroot/java/jar/jmi.jar
    ...
    

    The location within the classpath.txt (top or end of the file) appears to be of no importance.

    Modifying the classpath.txt may not be possible for all users, but there are work-arounds as listed on this excellent source of information: https://undocumentedmatlab.com/blog/static-java-classpath-hacks

提交回复
热议问题