Trouble compiling matlab function that calls Java
1 view (last 30 days)
Show older comments
I'm trying to compile some matlab code which calls one of the built in Java methods, e.g.:
function testJava()
docNode = com.mathworks.xml.XMLUtils.createDocument('root');
xmlwrite('sample.xml',docNode);
end
Compilation works fine, but when I attempt to execute the resulting file I get the following warning message:
"Warning: Unable to load Java Runtime Environment: libjvm.so: cannot open shared object file: No such file or directory
Disabling Java support"
This leads to the following error:
"Undefined variable "com" or class "com.mathworks.xml.XMLUtils.createDocument".
Error in testJava (line 2)"
Not sure if it is relevant or not, but I'm running the matlab2013a compiler on a linux-based computing core. Compiled matlab code which does not make use of java methods works just fine, as do uncompiled m-files which call java methods but are run directly through Matlab.
Thanks very much!
1 Comment
Answers (2)
Walter Roberson
on 18 Aug 2015
Did you add libjvm to the required library list?
2 Comments
Walter Roberson
on 19 Aug 2015
CFLAGS and CLIBS is the mechanism to use. -L the path to the java library and -llibjvm to indicate the library name.
I do not have the compiler to be able to find the exact file to look at or the place to configure if you are using the GUI version of the compiler tool; unfortunately the documentation for those requires a current support contract to access.
Steven Lord
on 19 Aug 2015
You said you compiled the code on a "linux-based computing core" -- if you try to compile the function from inside a MATLAB session, was that session started with -nojvm? If so, what happens when you started the MATLAB session in which you tried to compile that function WITHOUT the -nojvm startup flag?
0 Comments
See Also
Categories
Find more on Call Java from MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!