简体   繁体   English

为什么我的jar在Windows而不是Linux上可以工作

[英]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上唯一可能出错的可能是以下情况之一:

  1. you made a mistake with the classname argument 你用classname参数弄错了
  2. the application's classpath is incorrectly specified 应用程序的类路径指定不正确
  3. the wrong directory is on the classpath 错误的目录在类路径上
  4. the subdirectory path doesn't match the FQN 子目录路径与FQN不匹配
  5. dependencies missing from the classpath 类路径中缺少依赖项
  6. the class has been declared in the wrong package 该类已在错误的包中声明

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

For Ref : 对于参考

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

相关问题 .jar在Windows和Linux上有效,但在OSX上不可用 - .jar works on Windows and Linux but not OSX .jar 适用于 Windows 但不适用于 Linux (stacktrace) - .jar works in Windows but not Linux (stacktrace) 为什么我的游戏可以在Linux上正常运行,而不能在Windows上运行? (Java .jar) - Why does my game run fine on Linux, but not in Windows? (Java .jar) 为什么我的 Java 程序在 windows 中可以完美运行,但在 linux 中却是一场灾难? - Why my Java program works perfectly in windows but it's a disaster in linux? JAR 文件在 Linux 上按预期工作,在 Windows 上引发异常 - JAR file works as expected on Linux, throws exceptions on Windows 我的java代码在linux中正常工作但在Windows上不能正常工作 - My java code works properly in linux but not on Windows SimpleJdbcCall在Windows中有效,但在Linux中无效 - SimpleJdbcCall works in windows but not linux getResourceAsStream()在Windows上有效,但在Linux上无效 - getResourceAsStream() works on Windows but not on Linux 调用.jar文件在php shell_exec linux中不起作用,但在cmd和Windows中起作用 - Invoking .jar file doesn't work in php shell_exec linux but it works in cmd and windows JAR 文件在 Windows 上运行,但不在 Linux 上运行 - JAR file runs on Windows but not on Linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM