matlab deploytool to java package javac error

2019-07-14 17:57发布

问题:

I'm trying to wrap a program of mine to work with java. I tried a simple "hello world" first,

-hello world.m-

disp('hello world');

I used deploytool and selected java package.

when it reached this line: Executing command: "javac -verbose -classpath "C:\Program Files\MATLAB\R2009b\toolbox\javabuilder\jar\javabuilder.jar" -d "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\classes" "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\deployTutorial2\helloworld.java" "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\deployTutorial2\DeployTutorial2MCRFactory.java" "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\deployTutorial2\helloworldRemote.java" "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\deployTutorial2\package-info.java""

I got this error: 'javac' is not recognized as an internal or external command, operable program or batch file. Error: An error occurred while shelling out to javac (error code = 1). Unable to build executable.

btw: when I tried standalone application / c/c++ shared library it has been compiled successfully.

thanks in advance

回答1:

Possibly the Java SDK is not installed or properly configured on your machine. Open a system terminal and execute the following two commands:

java -version
javac -version

If they both work you should proceed with the examples from the MATLAB help. If not install the Java SDK.



回答2:

First you should install JAVA.
Then you must set the environment variable in "my computer"
Add a new variable named "JAVA_HOME" and set its value to your jdk path
like D:\Program\Java\jdk1.6.0_25
Then restart your matlab
and type

getenv JAVA_HOME  

you should get
ans=

D:\Program\Java\jdk1.6.0_25