简体   繁体   English

Java 9在Ubuntu上提供了“找不到主类”的信息,但文件在Windows和Mac上都可以// //如何在OpenJDK中找到主类

[英]Java 9 gives “Main Class not found” ob Ubuntu, but file works on Windows and Mac // how to find main Class in OpenJDK

So I have a jar file that works perfectly fine on Windows and Mac, but not on Ubuntu (the only place where Openjdk is installed) This question hints at OpenJDK being the problem: Java Application main class not found on Ubuntu So: how do I show OpenJDK the correct Main Class? 因此,我有一个jar文件,该文件在Windows和Mac上都可以正常运行,但在Ubuntu(无法安装Openjdk的唯一位置)上却无法正常工作。这个问题暗示了OpenJDK存在问题: 在Ubuntu上找不到Java应用程序主类。显示正确的MainJDK OpenJDK? (Its Client.class in /chat in the jar file) I know it has something to do with the MetaINF File, but I cant guess the correct input there. (其jar文件中/ chat中的Client.class)我知道它与MetaINF文件有关,但是我无法猜测那里的正确输入。 This is what's currently in the MANIFEST.MF file: 这是MANIFEST.MF文件中当前的内容:

Manifest-Version: 1.0 清单版本:1.0

Main-Class: Chat.Client 主类:Chat.Client

I cant find anything anywhere on the topic, but I also cant install the proprietary java on the Ubuntu PC, as its the one where the jar HAS to run and the one where I m not admin at. 我在该主题的任何地方都找不到任何东西,但是我也无法在Ubuntu PC上安装专有的Java,因为它是jar可以运行的地方,而我不是管理员。

Its Client.class in /chat in the jar file jar文件中/ chat中的Client.class

Then Main-Class: Chat.Client is incorrect, it should be Main-Class: chat.Client (lower case chat ). 然后Main-Class: Chat.Client不正确,应该是Main-Class: chat.Client (小写chat )。

So probably not an OpenJDK issue, just the fact that some file systems are case-insensitive and others are case-sensitive. 因此,可能不是OpenJDK问题,而是某些文件系统不区分大小写而另一些文件区分大小写的事实。 You're almost certainly using a case-insensitive one on Windows. 您几乎可以肯定在Windows上使用了不区分大小写的代码。 I guess you must be on Mac as well, though I find that surprising. 我想您也必须在Mac上,尽管我觉得很奇怪。 You probably aren't on Ubuntu. 您可能不在Ubuntu上。

Not really an answer but an easy workaround for people with the same Problem: Install (installing is optional, you can use it directly after the download) the proprietary JDK from Oracle, and if you dont have admin privileges (I dont): you dont need them, simply download the Java JDK from oracle and start the .Jar with /pathtothedownloadedJDK/bin/java instead of "java" and then the usual -jar yourJarFile.jar 对于那些具有相同问题的人来说,这不是真正的答案,而是一个简单的解决方法:从Oracle安装专有的JDK(安装是可选的,您可以在下载后直接使用它),并且如果您没有管理权限(我没有):您没有需要它们,只需从oracle下载Java JDK并使用/ pathtothedownloadedJDK / bin / java而不是“ java”启动.Jar,然后使用通常的-jar yourJarFile.jar

Tl:Dr: Get the JDK from Oracle, you dont need sudo to use it. Tl:Dr:从Oracle获得JDK,您不需要sudo即可使用它。

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

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