[英]Why my jar works on windows and not on linux
I am working on a Javafx application. 我正在研究Javafx应用程序。 I created the jar with intellij and artifact.
我用intellij和工件创建了jar。 The jar works very well on Windows.
该jar在Windows上运行良好。 However when I run it on linux it displays this error message:
但是,当我在linux上运行它时,它显示以下错误消息:
Erreur : impossible to find or load the main class view.View
Caused by : java.lang.NoClassDefFoundError: javafx/application/Application
It's probably a stupid mistake but I've been stuck on it for a long time..... I haven't found anything on the internet that could help me so if you have an idea or a useful link I'm very interested 这可能是一个愚蠢的错误,但是我已经坚持了很长时间.....我在互联网上找不到任何可以帮助我的东西,因此,如果您有想法或有用的链接,我会非常感兴趣
You most likely are missing an implementation of JavaFX. 您很可能缺少JavaFX的实现。 On most Linux distributions JavaFX is packages separate from the JDK.
在大多数Linux发行版中,JavaFX是与JDK分开的软件包。 The package is most likely called openjfx or something similar.
该软件包最有可能称为openjfx或类似名称。
If you are using Debian or a Debian based distribution such as Ubuntu you should be able to install openjfx by running: 如果您使用的是Debian或基于Debian的发行版(如Ubuntu),则应该能够通过运行以下命令安装openjfx:
$ sudo apt-get install openjfx $ sudo apt-get install openjfx
As you already said that the Jar is working correctly on Windows, so it is packaged ok. 就像您已经说过的那样,Jar在Windows上可以正常工作,因此打包就可以了。
The only thing that might be going wrong on Linux may be one of below: 在Linux上唯一可能出错的可能是以下情况之一:
There can be also version mismatch 也可能有版本不匹配
Type the following on your terminal - 在终端上输入以下内容-
javac -version
If you get javac 1.6.0_10 or later as the output then you will have to do the following steps. 如果将javac 1.6.0_10或更高版本作为输出,则必须执行以下步骤。 If you dont get the above output, you will have to un-install and re-install java.
如果未获得上述输出,则必须卸载并重新安装Java。
Steps to do if version shown is 1.6.0_10 or later Create symlink- 如果显示的版本是1.6.0_10或更高版本,请执行的步骤创建symlink-
ln -s /usr/local/java /usr/local/jdk1.6.0_10
Once that is done, add the following to your .bashrc file 完成后,将以下内容添加到您的.bashrc文件中
export JAVA_HOME=/usr/local/jdk1.6.0_10 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib 导出JAVA_HOME = / usr / local / jdk1.6.0_10导出PATH = $ JAVA_HOME / bin:$ PATH导出CLASSPATH = $ CLASSPATH:$ JAVA_HOME / lib
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.