I am trying to call Matlab (ver 7.10) from Java. I have received some autogenerated Java wrapper classes generated from Matlab Builder JA.
The Matlab program is extremely simple, it takes one parameter, prints it out and returns the same parameter again.
My Test Java class has a main method with this code:
public static void main (String[] args)
{
MWCharArray a = null;
TestTool2 test = null;
System.out.println("Starting");
try {
test = new TestTool2();
//Object[] result = test.testJava2(1, "Hello World");
a = new MWCharArray("Mary Smith");
Object[] result = test.testJava2(1, a);
for (int i=0; i < result.length; i++) {
System.out.println("Result=" + result[i]);
}
System.out.println("Done");
} catch (Throwable t) {
t.printStackTrace();
} finally {
a.dispose();
test.dispose();
}
System.out.println("Stopping");
}
When I run my program, I get some error messages. However the Matlab function is still called, it also prints out my input and return output correctly. Unfortunately after that the program just hangs. It never terminates. It does print out Stopping but never goes back to the command line prompt. What am I missing?
Here is the output of the program:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\work\code\neogrid\ifiv\test\MatlabTest\TestTool2>run
Starting
??? Error using ==> load
Unable to read file C:\Program Files (x86)\MATLAB\MATLAB Compiler
Runtime\v710\lastdir: No such file or directory.
Error in ==> startup at 1
Mary Smith
Result=Mary Smith
Done
Stopping