Error using load and program hangs
Show older comments
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
1 Comment
John Datson
on 6 Jul 2011
Accepted Answer
More Answers (1)
Kaustubha Govind
on 6 Jul 2011
Do you have a custom startup.m file in the MATLAB installation that you used to compile with MATLAB Builder JA? To locate it, type the following at the MATLAB prompt:
which startup
Examine this file to see if you have any LOAD commands to load data from a MAT-file. If yes, wrap them inside an IF statement checking for (~isdeployed), so that compiled applications do not attempt to execute these commands.
2 Comments
John Datson
on 6 Jul 2011
Kaustubha Govind
on 7 Jul 2011
John: Sorry, I'm not very familiar with Builder JA, so I don't know why you see additional threads created. Do you see similar behavior when deploying one of the documentation examples: http://www.mathworks.com/help/toolbox/javabuilder/ug/bsqrikz-1.html
If you don't get a reply here, it might be worth contacting Tech Support.
Categories
Find more on COM Component Integration 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!