问题
I use Jena FileManager to load a model from a local rdf file. The java code run correctly in Eclipse. But when I call this java class from matlab.
The partial source code is the following:
public static Set<String> getSubjectsRelatedToProperty(String filePath) throws IllegalArgumentException, URISyntaxException {
// read the resourceMap
FileManager fm = FileManager.get();
model = fm.loadModel(filePath);
return result_set;
}
The error I received is attached below.
--------------
Error Details:
--------------
Error using org.mycom/view (line 961)
Java exception occurred:
com.hp.hpl.jena.shared.NotFoundException: Not found: /Users/runs/1/abc.rdf
at com.hp.hpl.jena.util.FileManager.readModelWorker(FileManager.java:378)
at com.hp.hpl.jena.util.FileManager.loadModelWorker(FileManager.java:297)
at com.hp.hpl.jena.util.FileManager.loadModel(FileManager.java:248)
at org.mycom.QueryResourceMap.getSubjectsRelatedToProperty(QueryResourceMap.java:32)
回答1:
The root directory for your eclipse project is in a different location than your matlab project. That's the only problem i can think of. The file path you give, /Users/runs/1/abc.rdf
, contains a leading slash, which means the file search starts from the root directory of the application. I would probably just give an absolute file path, like C:/example/example/abc.rdf
.This way you can find the file no matter what program you give the file path to.
Or, just manually create your file path within the Matlab directory. So go to your matlab project root directory and create a Users
folder, then a runs
folder, etc...
来源:https://stackoverflow.com/questions/31712452/jena-filemanager-cannot-find-file