简体   繁体   English

Jar无法在Linux上执行

[英]Jar doesn't execute on linux

I exported an executable Jar file from Eclipse. 我从Eclipse导出了一个可执行的Jar文件。 On Windows when I double-click the file, it executes properly. 在Windows上,当我双击该文件时,它将正确执行。 When I run it from command line with java -jar MyJar.jar it also works. 当我使用java -jar MyJar.jar从命令行运行它时,它也可以工作。 But when I upload that file on my linux VPS and try to run it there, I just get the error 但是,当我在Linux VPS上上传该文件并尝试在其中运行该文件时,我得到了错误

Error: Could not find or load main class mypackage.MyClass 错误:找不到或加载主类mypackage.MyClass

I tried many things like changing CLASSPATH, trying out different Class-Paths and Main-Classes in the MANIFEST.MF file, and even trying to execute the program from .class files without the jar container. 我尝试了很多事情,例如更改CLASSPATH,尝试MANIFEST.MF文件中的不同Class-Paths和Main-Classes,甚至尝试从不带jar容器的.class文件执行程序。 But unfortunately nothing works. 但是不幸的是没有任何效果。

Do you have any ideas? 你有什么想法? Or did you face the same problem? 还是您遇到了同样的问题?

EDIT: 编辑:
Manifest: 表现:

Manifest-Version: 1.0
Class-Path: .
Main-Class: mypackage.MyClass

Name: about.html
SHA-256-Digest: 1fuYr0bu6NsJZCAmSom5QtnvnV0Cg8DwLn77Dd1Ql24=

Name: jfx8.cssext
SHA-256-Digest: b2p9PXeoxqnTdYgBFeKp3s7J9PajukOS3sGqyM4s36I=

I finally solved my problem!! 我终于解决了我的问题!

The problem was that no JavaFx runtime was installed on the VPS. 问题是VPS上没有安装JavaFx运行时。 Don't know why that caused that error. 不知道为什么会导致该错误。 I rewrote the Application without JavaFx and now it works. 我重写了没有JavaFx的应用程序,现在可以正常工作了。

Thank you for all your help. 谢谢你的帮助。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM