Why do I receive an invalid flag error message when compiling examples in the documentation for MATLAB Builder for Java 1.0 (R2006b)?

7 views (last 30 days)
I am trying to compile the magicsquare example in the documentation for MATLAB Builder for Java 1.0.
When I execute the command to compile getmagic.java,
javac -classpath
.;$MATLABROOT\toolbox\javabuilder\jar\javabuilder.jar;
.\distrib\magicsquare.jar getmagic.java
I receive the following error
javac: invalid flag: .\distrib\magicsquare.jar

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 2007a (R2007a). For previous product releases, read below for any possible workarounds:
There is an ambiguity in the documentation for MATLAB Builder for Java 1.0 (R2006b) when compiling the java components.
First, the command given in the documentation needs to be executed on a single line, however it is not clear where spaces need to be. Also, the documentation for the magicsquare example assumes that you have copied the file getmagic.java into the directory called magicsquare which was created by the builder
You can view this example by executing the following command at the MATLAB Command prompt.
web([docroot,'/toolbox/javabuilder/ug/bqppjqq-10.html#bqppjqr-13'])
After building the java project with DEPLOYTOOL, do the following to compile getmagic.java:
1. Copy getmagic.java into the project folder magicsquare created by DEPLOYTOOL. This folder should now have the file getmagic.java and two subdirectories, distrib and src.
2. Open a DOS command prompt, and change the directory to the folder magicsquare.
3. Execute the following command all on one line.
javac -classpath .;$MATLABROOT\toolbox\javabuilder\jar\javabuilder.jar;.\distrib\magicsquare.jar getmagic.java
(where $MATLABROOT is the MATLAB root directory on your machine, as returned by typing:
matlabroot
at the MATLAB command prompt.)
Note that there is a space between "-classpath" and ".;$MATLABROOT", but there is no space between "javabuilder.jar;" and ".\distrib".
Also, the command to execute the above example from the same directory as you compiled is:
java -classpath .;D:\Applications\MATLAB\R2006b\toolbox\javabuilder\jar\javabuilder.jar;.\distrib\magicsquare.jar -Djava.library.path=D:\Applications\MATLAB\R2006b\bin\win32;.\distrib getmagic 5

More Answers (0)

Categories

Find more on Java Package Integration in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2006b

Community Treasure Hunt

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

Start Hunting!