确定由 Matlab 加载的 Java 类的位置 [英] Determine location of a java class loaded by Matlab
本文介绍了确定由 Matlab 加载的 Java 类的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当使用 Matlab 中的 java 时,有什么方法可以确定从 matlab 的 java 类路径中加载类的位置吗?我正在尝试诊断由同时使用的同一类的冲突版本引起的错误.
When using java from Matlab, is there some way to figure out from where in matlab's java class path is a class being loaded? I'm trying to diagnose a error caused by conflicting versions of the same class being used simultaneously.
具体来说,我正在寻找的类是 org.apache.lucene.store.FSDirectory.好像是matlab工具箱之一用的,不知道是哪个.
Specifically, the class I'm looking for is org.apache.lucene.store.FSDirectory. It seems to be used by one of the matlab toolboxes, but I don't know which one.
推荐答案
来自 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/
这篇关于确定由 Matlab 加载的 Java 类的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文