Matlab figure to jar file
Show older comments
Hi
I want to save a matlab file to a java file such that i can have zooming, rotate options after saving the plot. I know that deploy tool is used for this. When i tried to run the mfile before building it using deploytool I am getting the following error message:
Undefined variable "MWMCR" or class "MWMCR.getCurrent".
Error in ==> javawebfigure at 6 runtime = MWMCR.getCurrent();
Error in ==> webfigure at 50 f = javawebfigure(hnd);
Error in ==> Myfilename at 18 wf = webfigure(handle) ;
I tried to build the file using the tool, but i got error message telling:
unable to build the code....
How to solve this problem? Is there any fix for this? Thanks in advance
Sreenu https://sites.google.com/site/kolukulasivasrinivas/
Accepted Answer
More Answers (2)
Kaustubha Govind
on 1 Dec 2011
I don't have any Java experience, but this is what I see in javawebfigure.m:
import com.mathworks.toolbox.javabuilder.internal.*; % for MWMCR
% get a reference to the current MCR
runtime = MWMCR.getCurrent();
So it looks like MATLAB cannot find the MWMCR class as expected in the com.mathworks.toolbox.javabuilder.internal.* package. I can see javabuilder.jar in $matlabroot/toolbox/javabuilder/jar/$arch - I'm assuming that this is what is required. Is the JAR file present in your MATLAB installation?
2 Comments
KSSV
on 2 Dec 2011
Kaustubha Govind
on 2 Dec 2011
Yes, it looks like you do have the correct files for R2010a (my answer mentions the directory structure for R2011b). Strange - I don't have any new ideas, sorry. If possible, you could try re-installing MATLAB to be sure it's not a corrupt install. If that doesn't work, try contacting Tech Support.
KSSV
on 9 Dec 2011
15 Comments
Friedrich
on 13 Dec 2011
Hi,
can you follow the example in the documentation? So start with an easy example like the one used in the documentation:
function df = getKnot()
f = figure('Visible','off'); %Create a figure.
%Make sure it isn't visible.
knot; %Put something into figure.
df = webfigure(f); %Give figure to function
% and return the result.
close(f); %Close the figure.
end
than use deploytool to create a jar file from this. After that proceed like explained in the doc:
http://www.mathworks.com/help/toolbox/javabuilder/ug/bryishq.html#bryi5ik
If you get an error during the build process, post the full log.
KSSV
on 14 Dec 2011
KSSV
on 14 Dec 2011
Friedrich
on 14 Dec 2011
hi,
seems like you set the uri from the taglib not correctly. try something like:
<%@taglib prefix="wf" uri="/WEB-INF/webfigures.tld"%>
KSSV
on 14 Dec 2011
Friedrich
on 14 Dec 2011
ah sorry this isnt needed for the default example. did you copy the javabuilder.jar to the tomcat lib subfolder and restarted the tomcat server? did you add the WebFigureQuickStart.war file correctly? is the $MATLABROOT\runtime\win32 or \win64 on your system path?
KSSV
on 14 Dec 2011
KSSV
on 14 Dec 2011
Friedrich
on 14 Dec 2011
great to hear that it works so far. Now proceed reading that part of the documentation. You will get to a point called: "Creating a Custom WebFigure". Follow all these steps and you will see your generated webfigure.
KSSV
on 14 Dec 2011
Friedrich
on 14 Dec 2011
If you dont have any JAVA skills why are you doing this in the first place?
But anyway. Its good to get an JAVA IDE. I personally use NET Beans:
http://netbeans.org/downloads/index.html
Start NETBeans and go to Tools -> Server and add your TomCat server there. After that start a new Project, chose Web Application. Open the index.jsp in your project and copy the code from the ML documentation in. In addition create that servlet and add a library link to the ML generated jar file. You see this is not that easy if one never worked with JAVA before.
I uploaded an example NETBeans project here:
https://rapidshare.com/files/3417896615/webapplication.zip
You will find all files you need. But you still have to create the Tomcat Server unter Tools -> Server.
KSSV
on 15 Dec 2011
KSSV
on 16 Dec 2011
Friedrich
on 16 Dec 2011
Not sure what causes this. But in normally this error means that java can't find a calls for which it is looking for. In this case a class from the javabuilder.jar. Did you copy the javabuilder.jar in the lib subfolder of your Apache installation? You can check this in the netbeans project under Libraries -> Apache Tomcat -> javabuilder.jar.
KSSV
on 19 Dec 2011
Categories
Find more on Get Started with MATLAB Compiler SDK 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!