Why do I get Java exception on display change

4 views (last 30 days)
I have linux system which I access through VNC. And modifying the display settings while Matlab is launched, gives Java Exceptions.
I found that it seems to be a common problem related to JDK 8, and the recommended work around is to modify the JVM options, or else upgrade the JDK.
Rather than upgrading the provided JDK, I tried modifying JVM options by creating the java.opts(/opt/MATLAB/R2017b/bin/java.opts) file as suggested on: https://www.mathworks.com/help/matlab/matlab_env/java-opts-file.html?s_tid=srchtitle
The option suggested to be added is the following:
So far, it seems to fix the problem, however I'm not sure if it's safe to disable the xrender.
And I've realized, for Matlab to take this file into account, I have to run the matlab command, from its binary folder (as if it's not defined in the PATH env variable).
If I directly run matlab command, and check for the JVM options through MATLAB Command window; as follows:
>> java.lang.management.ManagementFactory.getRuntimeMXBean.getInputArguments
I cannot see the necessary JVM option.
But unning the command otherwise; returns the correct output.
>> java.lang.management.ManagementFactory.getRuntimeMXBean.getInputArguments
ans =
[-Xms64m, -XX:NewRatio=3, -Xmx384m, -XX:MaxDirectMemorySize=2147400000, -XX:+AllowUserSignalHandlers, -Djava.ext.dirs=/opt/MATLAB/R2017b/sys/java/jre/glnxa64/jre/lib/ext, -Xrs, -Dsun.java2d.xrender=false, -Djava.library.path=/opt/MATLAB/R2017b/bin/glnxa64:/opt/MATLAB/R2017b/sys/jxbrowser/glnxa64/lib, vfprintf, -XX:ErrorFile=/home/hpcuser/hs_error_pid4292.log, abort, -Duser.language=en, -Duser.country=US, -Dfile.encoding=UTF-8, -XX:ParallelGCThreads=6]
My questions are:
  1. Is this a safe workaround
  2. if so; is there an automatic way to notify Matlab about the java.opts file.

Answers (0)


Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!