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

 採用された回答

Kojiro Saito
Kojiro Saito 2018 年 9 月 5 日

0 投票

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

6 件のコメント

ABHISHEK BHARDWAJ
ABHISHEK BHARDWAJ 2019 年 10 月 17 日
On my system it is saying
error: file not found: .\getmagic.java
Please tell me why?
Kojiro Saito
Kojiro Saito 2019 年 10 月 17 日
getmagic.java is to be created by yourself. In documentation of R2018b or earlier, you can find getmagic.java sample in "Java Code to Implement Application".
https://www.mathworks.com/help/releases/R2018b/compiler_sdk/gs/create-a-java-application-with-matlab-code.html
From R2019a, the java code is included in for_redistribution_files_only\samples folder.
ABHISHEK BHARDWAJ
ABHISHEK BHARDWAJ 2019 年 10 月 17 日
Thank you for the reply, I have followed the process given in the link.
While installing MaAppInstaller_mcr.exe following error occurs :
Internal error: Failed to initialize application installer (204)
I am using MATLAB 2018a.
ABHISHEK BHARDWAJ
ABHISHEK BHARDWAJ 2019 年 10 月 17 日
I am using matlab 2018a. After following the full process of following link
in the last step of executing following command ->
F:\makesqr\for_redistribution_files_only>java -classpath .;"C:\Program Files\MAT
LAB\MATLAB Runtime\v94\toolbox\javabuilder\jar\javabuilder.jar";.\makesqr.jar ge
tmagic 5
this error is generated ->
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: getmagic has
been compiled by a more recent version of the Java Runtime (class file version 5
5.0), this version of the Java Runtime only recognizes class file versions up to
52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
How this error can be resolved?
Kojiro Saito
Kojiro Saito 2019 年 10 月 18 日
The class file version is 55.0, so I guess you have compiled getmagic.java by Java 11.
JVM in MATLAB R2018a (MATLAB Runtime v94) is Java 1.8.0_144, so you need to do javac by Java 8.
ABHISHEK BHARDWAJ
ABHISHEK BHARDWAJ 2019 年 10 月 18 日
Thank you very much...It worked...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Deploy to Java Applications Using MWArray Data API についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by