MATLAB: Create a Java Package with MATLAB Code Error

MATLABMATLAB CompilerMATLAB Compiler SDK

I follow the following example:
In this step,
Compile the Java application using javac.
javac -classpath "mcrroot\toolbox\javabuilder\jar\javabuilder.jar";.\makesqr.jar .\getmagic.java
The cmd prompted the error :
.\getmagic.java:4: error: error while writing getmagic: C:\Program Files\makesqr\application\getmagic.class class getmagic ^ 1 error

Best Answer

This is due to file access permissions. In my case, I got the following error.
C:\Program Files\makesqr\application>javac -classpath "C:\MATLAB\MATLAB_Runtime\v94\toolbox\javabuilder\jar\javabuilder.jar";.\makesqr.jar .\getmagic.java
.\getmagic.java:4: error: error while writing getmagic: .\getmagic.class (Access is denied)
class getmagic
^
1 error
javac tries to create getmagic.class file, but normal users do not have a permission to write a file under C:\Program Files.
I think there are two options.
  1. Launch command prompt as Administrator, then execute the javac command.
  2. Install makesqr package in another folder where normal users have a permission to write