Overview of MATLAB Builder JA Java integration » History » Version 1
Chris Cannam, 2014-03-11 03:11 PM
1 | 1 | Chris Cannam | h1. Overview of MATLAB Builder JA Java integration |
---|---|---|---|
2 | 1 | Chris Cannam | |
3 | 1 | Chris Cannam | h1. MatlabBuilderJA |
4 | 1 | Chris Cannam | |
5 | 1 | Chris Cannam | Need to add the javabuilder.jar Library to the Apache Tomcat folder of global JARs: |
6 | 1 | Chris Cannam | |
7 | 1 | Chris Cannam | * javabuilder.jar location: @$(MATLAB_HOME)/toolbox/javabuilder/jar/@ |
8 | 1 | Chris Cannam | * Tomcat lib dir: @$(TOMCAT_HOME)/lib@ |
9 | 1 | Chris Cannam | |
10 | 1 | Chris Cannam | h2. Creating a dummy Java webapp: End to End Example |
11 | 1 | Chris Cannam | |
12 | 1 | Chris Cannam | * See page 119 from the "Matlab Javabuilder Example Guide":http://www.mathworks.co.uk/help/pdf_doc/javabuilder/example_guide.pdf |
13 | 1 | Chris Cannam | |
14 | 1 | Chris Cannam | # Download the code from "MATLAB Central":http://www.mathworks.com/matlabcentral/fileexchange/22476-java-web-example-guide-end-to-end-chapter |
15 | 1 | Chris Cannam | # Make sure the path for MATLAB's libraries is correctly set: |
16 | 1 | Chris Cannam | <pre> |
17 | 1 | Chris Cannam | export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/MATLAB_R2013b.app/sys/os/maci64/:/Applications/MATLAB_R2013b.app/runtime/maci64/:/Applications/MATLAB_R2013b.app/bin/maci64/ |
18 | 1 | Chris Cannam | </pre> |
19 | 1 | Chris Cannam | # Copy your web servers servlet-api.jar file into this directory; |
20 | 1 | Chris Cannam | # Copy the javabuilder.jar file from your MATLAB or MCR install root in the directory /toolbox/javabuilder/jar/javabuilder.jar to the web applications lib folder ./webapp/WEB-INF/lib |
21 | 1 | Chris Cannam | # Recompile the MATLAB component by running the following MCC command: |
22 | 1 | Chris Cannam | <pre> |
23 | 1 | Chris Cannam | /Applications/MATLAB_R2013b.app/bin/mcc -W "java:examples,MagicCalc" -d ./scratch -T "link:lib" -v "class{MagicCalc:./webapp/WEB-INF/mcode/getMagic.m,./webapp/WEB-INF/mcode/getMagicWebFigure.m}" |
24 | 1 | Chris Cannam | </pre> |
25 | 1 | Chris Cannam | #* this will generate the contents of scratch |
26 | 1 | Chris Cannam | # Copy the deployed component from the scratch folder to the web applications lib folder .\webapp\WEB-INF\lib |
27 | 1 | Chris Cannam | <pre> |
28 | 1 | Chris Cannam | cp ./scratch/examples.jar ./webapp/WEB-INF/lib |
29 | 1 | Chris Cannam | </pre> |
30 | 1 | Chris Cannam | # Compile the web application making sure to reference the servlet-api.jar, the deployed component jar, and the javabuilder.jar |
31 | 1 | Chris Cannam | <pre> |
32 | 1 | Chris Cannam | javac -cp servlet-api.jar:./webapp/WEB-INF/lib/javabuilder.jar:./webapp/WEB-INF/lib/examples.jar: -d ./webapp/WEB-INF/classes ./webapp/WEB-INF/src/MagicSquareServlet.java |
33 | 1 | Chris Cannam | </pre> |
34 | 1 | Chris Cannam | # Navigate to the web applications directory and create the war file. |
35 | 1 | Chris Cannam | <pre> |
36 | 1 | Chris Cannam | cd webapp |
37 | 1 | Chris Cannam | jar -cvf ../JavaEndToEnd.war . |
38 | 1 | Chris Cannam | cd .. |
39 | 1 | Chris Cannam | </pre> |
40 | 1 | Chris Cannam | # Copy this JavaEndToEnd.war file into your web servers webapps directory |
41 | 1 | Chris Cannam | # Start the web server and navigate in a browser to the following url: |
42 | 1 | Chris Cannam | <pre> |
43 | 1 | Chris Cannam | http://localhost:8080/JavaEndToEnd/ExamplesPage.jsp |
44 | 1 | Chris Cannam | </pre> |
45 | 1 | Chris Cannam | |
46 | 1 | Chris Cannam | |
47 | 1 | Chris Cannam | h3. Folder Structure |
48 | 1 | Chris Cannam | |
49 | 1 | Chris Cannam | <pre> |
50 | 1 | Chris Cannam | JavaEndToEnd/ |
51 | 1 | Chris Cannam | ├── scratch |
52 | 1 | Chris Cannam | │ ├── classes |
53 | 1 | Chris Cannam | │ │ └── examples |
54 | 1 | Chris Cannam | │ ├── doc |
55 | 1 | Chris Cannam | │ │ └── html |
56 | 1 | Chris Cannam | │ │ ├── examples |
57 | 1 | Chris Cannam | │ │ └── resources |
58 | 1 | Chris Cannam | │ └── examples |
59 | 1 | Chris Cannam | └── webapp |
60 | 1 | Chris Cannam | └── WEB-INF |
61 | 1 | Chris Cannam | ├── classes |
62 | 1 | Chris Cannam | ├── lib |
63 | 1 | Chris Cannam | ├── mcode |
64 | 1 | Chris Cannam | └── src |
65 | 1 | Chris Cannam | </pre> |
66 | 1 | Chris Cannam | |
67 | 1 | Chris Cannam | |
68 | 1 | Chris Cannam | * "Using Ant to create a WAR ":https://ant.apache.org/manual/Tasks/war.html |
69 | 1 | Chris Cannam | * "Very simple webapp - JAVA, Ant":http://static.springsource.com/projects/tc-server/6.0/getstart/tgsdevtut.html |