简体   繁体   English

java.lang.NoClassDefFoundError:无法初始化类java.awt.Component

[英]java.lang.NoClassDefFoundError: Could not initialize class java.awt.Component

When I run MATLAB install script in Ubuntu, I get the following exception: 当我在Ubuntu中运行MATLAB安装脚本时,我得到以下异常:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class java.awt.Component

longer output is available here 这里有更长的输出

I know that it's a Java problem and could potentially be fixed by changing the classpath or something like that but I don't exactly know how. 我知道这是一个Java问题,可以通过更改类路径或类似的东西来修复,但我不知道如何。

Any Ideas? 有任何想法吗?

For me this error was fixed when I installed the JRE on my system: 对我来说,当我在我的系统上安装JRE时,此错误已得到修复:

apt-get install default-jre

on Ubuntu 12.04, instead of having MATLAB use its own. 在Ubuntu 12.04上,而不是让MATLAB使用它自己的。

I've been battling this problem for the whole evening as well but I stumbled onto a solution that works for me at least. 我整个晚上一直在和这个问题作斗争,但我偶然发现了一个对我有用的解决方案。

After trying to install using the silent installer I got a different error with a bit more information. 尝试使用静默安装程序进行安装后,我收到了一个不同的错误信息。 It turned out that a library was missing (libXtst.so.6). 原来,缺少一个库(libXtst.so.6)。 I was able to install that on my Ubuntu system with: 我能够在我的Ubuntu系统上安装:

apt-get install libxtst6

After that I tried running the GUI installer (over X forwarding) and it looks like it's going to work now. 之后我尝试运行GUI安装程序(通过X转发),看起来它现在可以正常工作了。

For MATLAB R2012a Student Edition, in Ubuntu 14.04, I had to install these prerequisites first: 对于MATLAB R2012a学生版,在Ubuntu 14.04中,我必须首先安装这些先决条件:

sudo apt-get install default-jre libxtst6:i386 libXext6:i386 libxi6:i386 libncurses5:i386 libxt6:i386 libxpm4:i386 libxmu6:i386 libxp6:i386

Next I installed/activated per MATLAB's instructions ( sudo ./install ). 接下来我根据MATLAB的说明安装/激活( sudo ./install )。 I answered "yes" when the installer asked to add a symbolic link in /usr/local/bin/ 当安装程序要求在/ usr / local / bin /中添加符号链接时,我回答“是”

Finally, when launching MATLAB, I have to specify that it run in 32-bit mode: 最后,在启动MATLAB时,我必须指定它以32位模式运行:

matlab -glnx86

I assembled those steps from this answer: https://askubuntu.com/questions/363878/how-to-install-32-bit-matlab-in-ubuntu-64-bit 我从这个答案中汇总了这些步骤: https//askubuntu.com/questions/363878/how-to-install-32-bit-matlab-in-ubuntu-64bit

and the Ubuntu MATLAB guide: https://help.ubuntu.com/community/MATLAB 和Ubuntu MATLAB指南: https//help.ubuntu.com/community/MATLAB

Optional 可选的

I didn't want to type the -glnx86 option each time I launch MATLAB, so I replaced the matlab symbolic link in /usr/local/bin/ with a script that automatically specifies the -glnx86 option: 每次启动MATLAB时我都不想输入-glnx86选项,所以我用自动指定-glnx86选项的脚本替换/ usr / local / bin /中的matlab符号链接:

ls -l /usr/local/bin/matlab #note the destination of the symbolic link
sudo mv /usr/local/bin/matlab /usr/local/bin/matlab.bak
#ensure the first path below matches your symbolic link's destination
echo '/usr/local/MATLAB/R2012a_Student/bin/matlab -glnx86  "$@"' | sudo tee /usr/local/bin/matlab
sudo chmod +x /usr/local/bin/matlab

With that, I can type 'matlab' and it launches properly. 有了它,我可以输入'matlab'并正确启动它。 (The "$@" in the script forwards all input arguments to matlab.) There's probably a more elegant way to accomplish this, but it worked. (脚本中的"$@"将所有输入参数转发给matlab。)可能有更优雅的方法来实现这一点,但它有效。

I also encountered a "/lib/libc.so.6: not found" error on matlab startup, which I fixed by following this answer . 我在matlab启动时遇到了“/lib/libc.so.6:not found”错误,我通过这个答案修复了这个错误。

Installing gnome (sudo apt-get install gnome) fixed this problem for me. 安装gnome(sudo apt-get install gnome)为我解决了这个问题。 I'm sure this was total overkill, but the required libraries are now available. 我确信这是完全矫枉过正的,但现在可以使用所需的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError:无法初始化类 - java.lang.NoClassDefFoundError: Could not initialize class java.lang.NoClassDefFoundError:无法初始化类 - java.lang.NoClassDefFoundError: Could not initialize class java.lang.NoClassDefFoundError: 无法初始化 class java.awt.Toolkit - java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit java.lang.NoClassDefFoundError:无法初始化类business.HibernateUtil - java.lang.NoClassDefFoundError: Could not initialize class business.HibernateUtil Spring:java.lang.NoClassDefFoundError:无法初始化类 - Spring: java.lang.NoClassDefFoundError: Could not initialize class java.lang.NoClassDefFoundError:无法初始化类 XXX - java.lang.NoClassDefFoundError: Could not initialize class XXX java.lang.NoClassDefFoundError: 无法初始化类 | 静态块 - java.lang.NoClassDefFoundError: Could not initialize class | static block java.lang.NoClassDefFoundError: 无法初始化 class - Kotlin Object - java.lang.NoClassDefFoundError: Could not initialize class - Kotlin Object ECLIPSE:java.lang.NoClassDefFoundError:无法初始化类**** - ECLIPSE: java.lang.NoClassDefFoundError: Could not initialize class **** java.lang.NoClassDefFoundError:无法初始化类x - java.lang.NoClassDefFoundError: Could not initialize class x
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM