Matlab figure to jar file

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

Friedrich
Friedrich on 2 Dec 2011

0 votes

Hi,
where should the java application run at the end? Are you designing a web application or a classical java application?
A webfigure is designed to be displayed on a webpage, example here:
You can't translate a figure directly to a JAVA component. You can create the figure on the ML side, save it as a .fig and write a function which open that fig file. Than you compile that m file which can be executed from JAVA which will than show you the figure.

4 Comments

Hi Friedrich
Thanks for the response. Yes I want to design the figure to display in webpage. The documentation link you have given is useful for me I believe, I will go through and get back to you.
Sreenu
http://sites.google.com/site/kolukulasivasrinivas/
Hi Friedrich
I read the documentation, I downloaded and installed tomcat. Changed the tomcat-users accordingly given in the documentation, but when I log in with the username and password I am unable to log in. I have removed comments as well..Below are the lines I have changed to:
<role rolename="manager"/>
<role rolename="admin"/>
<user username="sreenu" password="energy" roles="admin,manager-gui,
manager-script"/>
I have tried changing those words to many ways (permutations)
But I never could log in to the manager App..Where I am going wrong?
I have no idea about JAVA.I think to use this option JAVA knowledge is not required.
Thanking you
Sreenu
http://sites.google.com/site/kolukulasivasrinivas/
did you put it in with that linebreak in the role? if so, it wont work I think. Please make sure that the <user username="sreenu" password="energy" roles="admin,manager-gui, manager-script"/> is one line without a break.
Hi
Sorry for delayed reply....I could log in to tomcat. To deploy a matlab figure into homepage we can this tomcat. But prior to this we must have jar file ready to deploy. I am unable to make jar file for matlab figure. I get the error:
import com.mathworks.toolbox.javabuilder.internal.*; % for MWMCR
% get a reference to the current MCR
runtime = MWMCR.getCurrent();
What is the solution for this?
Sreenu

Sign in to comment.

More Answers (2)

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

Hi
Thanks for the response.
I checked in $matlabroot/toolbox/javabuilder/jar/ in this I have two files javabuilder, WebFigureQuickStart.war.I think the arch one is not there. I am using R2010a is it not available in this version?
Thanking you
Sreenu
https://sites.google.com/site/kolukulasivasrinivas/
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.

Sign in to comment.

KSSV
KSSV on 9 Dec 2011
Hi
I have installed the Matlab Compiler Run time. After installation, when I run the m-file which has webfigure command in it is running good. I am getting the following response:
ans =
com.mathworks.toolbox.javabuilder.webfigures.WebFigure@6f4a71dd
Earlier I had MCR error. Now it is cleared. But when I deploy it using deploytool, I am unable to build jar file. I am getting the following error:
Error: An error occurred while shelling out to javac (error code = -1). Unable to build executable.
Any one can help me on this? Thanks in advance.
Sreenu
https://sites.google.com/site/kolukulasivasrinivas/

15 Comments

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
KSSV on 14 Dec 2011
Hi
There was some environmental settings problem, after setting these values I am able to get jar file. I am following up the next with the tomcat from the doc link which you have given. I will let you know the result...
Thanking you
Sreenu
https://sites.google.com/site/kolukulasivasrinivas/
KSSV
KSSV on 14 Dec 2011
Hello
I have followed the steps exactly what is in documentation. I tried opening default figure first (Matlab's logo). I am not getting default figure. Error is as follows:
Unable to load tag handler class "com.mathworks.toolbox.javabuilder.webfigures.jsp.JspWebFigureTagHandler" for tag "wf:web-figure"
What is the solution?
Sreenu
https://sites.google.com/site/kolukulasivasrinivas/
hi,
seems like you set the uri from the taglib not correctly. try something like:
<%@taglib prefix="wf" uri="/WEB-INF/webfigures.tld"%>
KSSV
KSSV on 14 Dec 2011
Hi
Where to find the taglib?
Sreenu
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
KSSV on 14 Dec 2011
Yes I have copied the javabuilder.jar to the tomcat lib. WebFigureQuickStart.war file I have deployed, and the message says ok.
in syatem path I have $MATLABROOT\runtime\win32...
And I have other doubt when I run https:\\sreenu.8080 for tomcat it displays cannot be connected...How to overcome this?
KSSV
KSSV on 14 Dec 2011
Hi
I have re-installed tomcat again...switched on the service and followed all the lines again...now I am able to see the default figure...Thank god..moved a bit...Now, how I can open jar files created form the builder ja...
Thanking you
sreenu
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
KSSV on 14 Dec 2011
Hi
I am trying the next, but it is bit confusing..DO we need to copy the jar file obtained from matlab builder ja in the wen inf of tomcat folder???How to make xml file? n this I need to copy the lines given in documentation. I have many questions because am zero in java...
Thanks
Sreenu
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
KSSV on 15 Dec 2011
Oh
Thanks a lot. I have already installed Netbeans in my system. I am on the way of learning JAVA. I wanted to save MATLAB figure to upload on web such that it have pan, zoom, rotate options. I explored and found that this is the way.
I am trying the lines you wrote...
Thanks a lot....Will let you know the result..
Sreenu
KSSV
KSSV on 16 Dec 2011
Hi
I have followed all the lines with the help of you project. I am getting the following error:
Unable to load tag handler class "com.mathworks.toolbox.javabuilder.webfigures.jsp.JspWebFigureTagHandler" for tag "wf:web-figure"
Sreenu
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
KSSV on 19 Dec 2011
Hi
I am trying it...But I managed to get what I needed from the following http://www.mathworks.com/matlabcentral/fileexchange/32207
Which is very more simpler then this one...
Thanks a lot

Sign in to comment.

Categories

Asked:

on 1 Dec 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!