Filter löschen
Filter löschen

"Java not enabled" in deployed app

6 Ansichten (letzte 30 Tage)
chris
chris am 14 Feb. 2020
Kommentiert: Sabine Eckhardt am 5 Mär. 2020
To showcase the issue, consider the following simple function:
function checkJavaVersion
version -java
When I execute it in Matlab I receive the following result:
>> checkJavaVersion
ans =
'Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode'
Now I am using the Matlab Compiler to deploy this function:
mcc -m checkJavaVersion.m
And I execute it in a machine (the same one that built the function) with the Matlab Runtime installed:
./run_checkJavaVersion.sh /usr/local/MATLAB/MATLAB_Runtime/v97
And here is the response:
------------------------------------------
Setting up environment variables
---
LD_LIBRARY_PATH is .:/usr/local/MATLAB/MATLAB_Runtime/v97/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v97/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v97/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v97/sys/opengl/lib/glnxa64
ans =
'Java is not enabled'
How could Java be enabled in such a scenario?
  1 Kommentar
chris
chris am 14 Feb. 2020
I should also point out that this was tested on Ubuntu 19.10.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

chris
chris am 17 Feb. 2020
In case anyone else encounters this issue of JVM not being available in compiled Matlab apps (e.g. due to compiling p-coded files) here is the solution:
From Matworks support:
"MATLAB Compiler, during the dependency analysis, actually tries to determine whether your application requires Java or not. If the analysis concludes your application does not require Java, Java support is indeed automatically disabled when you run the application, this is expected behavior; this increases startup performance and reduces resource (mainly memory) usage."
So in the aforementioned example one should modify the function to include a command that requires Java, e.g.:
function checkJavaVersion
% Actually do something using Java
javaString = java.lang.String('myString');
version -java
  2 Kommentare
Sabine Eckhardt
Sabine Eckhardt am 4 Mär. 2020
I think I am having exactly the same problem, however use R2019a and I get in the end not a succeed, but following message:
------------------------------------------
Setting up environment variables
---
LD_LIBRARY_PATH is .:/usr/local/MATLAB/MATLAB_Runtime/v96//runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v96//bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v96//sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v96//sys/opengl/lib/glnxa64
Undefined variable "java" or class "java.lang.String".
Error in checkjava (line 2)
MATLAB:undefinedVarOrClass
Sabine Eckhardt
Sabine Eckhardt am 5 Mär. 2020
working after upgrading to R2019b

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Java Package Integration finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by