Effacer les filtres
Effacer les filtres

How to compile and deploy SimBiology file on the web

2 vues (au cours des 30 derniers jours)
Zetty  Zakaria
Zetty Zakaria le 22 Juil 2014
Commenté : Martijn le 29 Juil 2014
Hi everyone. Really need someone to assist me on this matter. I have an *.sbproj file. I know that we need to export the file and use the exported model in order to deploy it in a standalone application. But, how can I use this file for the deployment in the web? I don't have any idea on how to create the *.jar file for this case. One of the example show it this way (for standalone application),
mccCommand = ['mcc -m T1.m -N -p simbio -a exportedM1.mat', dependencies_2];
But since I need it to be in a *.jar file, I don't know how to do it. Hope someone could show me the right way to do this. Any examples will be very much appreciated. For your information, I am using Eclipse Kepler to build Java servlet and JSP and using Tomcat as the server. Thanks in advance!

Réponse acceptée

Arthur Goldsipe
Arthur Goldsipe le 22 Juil 2014
Hi Zetty,
You need to take two additional steps to update this example to work with MATLAB Builder JA.
First, you need to modify the mcc command so that it produces a Java jar file instead of an executable. You do that by changing the -m option to something like -W java:package,Class. Replace package by the package you want the generated Java classes stored in, and replace Class with the name you want to use for the main class in this package. For example, to create a class named SBApp in a package pkg, you can update your sample code as follows:
mccCommand = ['mcc -W ''java:pkg,SBApp'' T1.m -N -p simbio -a exportedM1.mat ', ...
dependencies_2];
Second, you need to create a Java class that somehow runs the class in this jar file. To learn the details on that, you should inspect the generated Java code and the MATLAB Builder JA documentation. However, here's a simple class that will run the Java class created with the command above, wait until all figures are closed, and then exit:
import com.mathworks.toolbox.javabuilder.*;
import pkg.SBApp;
public class runApp {
public static void main(String[] args) {
try {
SBApp app = new SBApp();
try {
app.T1();
app.waitForFigures();
} finally {
app.dispose();
}
} catch (MWException e) {
e.printStackTrace();
}
}
}
  6 commentaires
Zetty  Zakaria
Zetty Zakaria le 27 Juil 2014
Hi Arthur, thanks again! I have actually tried to work backward, where I have exported the SimBiology as equation and save all the equations in a matlab function file. It works great! But I think it's just like a redundant works. But still, your answers help me a lot! Will continue the question with Technical Support. Thanks!
Martijn
Martijn le 29 Juil 2014
To clarify: MATLAB Builder JA does indeed support showing MATLAB GUIs locally when using a MATLAB Builder JA class in a local Java application. It does not support displaying those GUIs in a browser when the classes are used in a Web Application though.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Import Data dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by