PDA

查看完整版本 : 确定Matlab加载的Java类的位置


poster
2019-12-10, 16:49
在Matlab中使用Java时,是否有某种方法可以找出从matlab的java类路径中的哪个位置加载类?我正在尝试诊断由于同时使用同一类的版本冲突而导致的错误。

具体来说,我要查找的类是org.apache.lucene.store.FSDirectory。它似乎由matlab工具箱之一使用,但我不知道是哪一个。


回答:
来自http://www.exampledepot.com/egs/java.lang/ClassOrigin.html

// Get the location of this class Class cls = this.getClass(); ProtectionDomain pDomain = cls.getProtectionDomain(); CodeSource cSource = pDomain.getCodeSource(); URL loc = cSource.getLocation(); // file:/c:/almanac14/examples/

更多&回答... (https://stackoverflow.com/questions/1127166)