Why do I receive "Fatal Error on startup: Java exception occurred: java.lang.​NoClassDef​FoundError​: Could not initialize class com.mathwo​rks.servic​es.binding​.MatlabKey​Bindings" when starting MATLAB on Linux or macOS?

40 次查看(过去 30 天)
Why do I receive "Fatal Error on startup: Java exception occurred:  java.lang.NoClassDefFoundError: Could not initialize class com.mathworks.services.binding.MatlabKeyBindings" when starting MATLAB on Linux or macOS?

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2023-5-8
This error indicates that MATLAB is not able to locate or read your MATLAB preferences directory. This could be due to a setting or variable on your system which is causing MATLAB to look for your preferences in a location where you do not have read access.
Typically this happens due to running a configuration script for MATLAB such as ‘config_matlab.sh’ which attempts to set your preferences directory to a non-default location where you do not have read or write access. You should start by removing the portion of the script which sets your environment variable.
This can also be resolved by creating an environment variable to specify your MATLAB preferences directory immediately before starting MATLAB. You should choose a directory where you have both read and write access. The default location is in your home folder. As an example of the command to run before starting MATLAB, see the following:
Linux
export MATLAB_PREFDIR=~/.matlab/R2023a
/usr/local/MATLAB/R2023a/bin/matlab
Mac
export MATLAB_PREFDIR=~/.matlab/R2023a
/Applications/MATLAB_R2023a.app/bin/matlab
This command sets your MATLAB preferences directory to be the default directory inside your home folder. Then, on the next line, the command is to launch MATLAB.
  1 个评论
Walter Roberson
Walter Roberson 2017-12-15
The above bit about environment variables is for OS-X/MacOS and for Linux, and assumes that the user is using a shell derived from ksh . However, ksh and derivatives are case sensitive, and the command in them is export rather than Export . Also the second line needs to begin with /
export MATLAB_PREFDIR=~/.matlab/R2015a
/usr/local/MATLAB/R2015a/bin/matlab
/usr/local/MATLAB is used for Linux but in OS-X /MacOS the equivalent would be
/Applications/MATLAB_R2015a.app/bin/matlab

请先登录,再进行评论。

更多回答(1 个)

David
David 2015-8-31
I want to report another common reason matlab on linux would be unable to read the preferences file. I often run matlab over a VPN I establish to the head node of a computer cluster. I then use matlab to submit parallel jobs to the compute nodes. Sometimes, I'll have more than one VPN tunnel established at once- one from a work computer, then later another from my laptop, or maybe from a different work computer. None of my tunnels can see the other's applications, so I end up running multiple copies of matlab operating out of my same user folder.
If one matlab opens the preference file for writing, perhaps because I made a change to the window arrangement, then when I attempt to open the second matlab through a different terminal, I receive this error.
If this applies to anyone else, the solution is that if you change the preferences in one instance of matlab, reboot this one before trying to open other instances. If you already have multiple instances running when you change the preferences from one instance, the others will stay open, but will throw this error when you try to reboot them.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

尚未输入任何标签。

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by