简体   繁体   English

在Windows上创建的jar在Linux上不起作用

[英]jar created on windows doesn't work on linux

I exported a runnable jar from Eclipse on windows 8.1. 我在Windows 8.1上从Eclipse导出了一个可运行的jar。 When I try t tun it on kali linux it gives 'Invalid or corrupt jarfile' 当我尝试在kali linux上对其进行调整时,它给出了“无效或损坏的jarfile”

I then created the jar using intellij, but it give the same error on kali linux. 然后,我使用intellij创建了jar,但在kali linux上却给出了相同的错误。

Jar works fine on my windows system created by either method. Jar可以在我用任何一种方法创建的Windows系统上正常工作。 I am using oracle jdk 6 to export the jar. 我正在使用oracle jdk 6导出jar。 On kali linux I have openjdk installed. 在kali linux上,我安装了openjdk。

Oupout of unzip DocUploder.jar on kali linux 在Kali Linux上unzip DocUploder.jar

Archive:  DocUploder.jar
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
note:  DocUploder.jar may be a plain executable, not an archive
unzip:  cannot find zipfile directory in one of DocUploder.jar or
        DocUploder.jar.zip, and cannot find DocUploder.jar.ZIP, period.

Well, since the answer is obvious after the long chat I'd provide the action list that helps to find problem like "my jar does not run". 好吧,由于经过长时间的聊天之后答案很明显,因此我将提供操作列表以帮助查找“我的jar无法运行”之类的问题。

  1. Check the command line. 检查命令行。 Be sure the classpath is correct. 确保类路径正确。
  2. Check the error message. 检查错误消息。 If it complains that jar is corrupted, check jar. 如果它抱怨jar损坏,请检查jar。 If it complains about the class version check JRE version. 如果抱怨类版本,请检查JRE版本。 If it throws ClassNotFoundException or ClassDefNotFoundError check classpath. 如果抛出ClassNotFoundExceptionClassDefNotFoundError检查类路径。 If it throws NoSuchMethodException or similar check compatibility of your libraries. 如果抛出NoSuchMethodException或类似内容,请检查您的库的兼容性。
  3. To check jar file try jar vft your.jar (if you have JDK) or commands like unzip on linux or extract zip file on windows. 要检查jar文件,请尝试jar vft your.jar (如果您有JDK)或诸如在Linux上unzip或在Windows上unzip zip之类的命令。 If this does not work - jar file is corrupted. 如果这不起作用-jar文件已损坏。
  4. If jar file runs on one machine and does not run on other check how did you copy the file. 如果jar文件在一台计算机上运行而在另一台计算机上未运行,请检查如何复制该文件。 First check the file size on both machines. 首先检查两台计算机上的文件大小。 Use ls -l on unix or dir on windows. 在Unix上使用ls -l或在Windows上使用dir If files have the same size try to compare them by creating hash. 如果文件大小相同,请尝试通过创建散列来比较它们。 Use md5sum my.jar on linux and tool like WinMd5 on windows. 使用md5sum my.jar在Linux和工具,如WinMd5在Windows上。 Other possibility is to copy file forward and back and check that it is still ok. 另一种可能性是向前和向后复制文件,并检查它仍然可以。

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

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