gpt4 book ai didi

java - 无法从 Windows 上的 jar 加载 Main-Class list 属性

转载 作者:可可西里 更新时间:2023-11-01 11:19:42 27 4
gpt4 key购买 nike

我在 linux 中执行一个 jar,它工作正常这是命令:

 java -Djava.ext.dirs=/home/amira/workspace/srd/remap/libs fr.srd.remap.compiler.main.Main ~/Desktop/TDP/VQHFACCOI/VQHFACCOI.xml ~/Desktop/TDP/VQHFACCOI

所以对于技术问题,我需要在 Windows 机器上运行它,所以这里是使用的命令:

C:\Documents and Settings\walinbj\Desktop\remap-to-win>java -jar remap.jar -Djava.ext.dirs=Facture\libs fr.srd.remap.compiler.Main  C:\Documents and Settings\walinbj\Desktop\remap-to-win\Facture\TDPFAC010.xml

我收到此错误 无法从中加载 Main-Class list 属性
重映射.jar

最佳答案

来自javadocs :

设置应用程序的入口点

If you have an application bundled in a JAR file, you need some way toindicate which class within the JAR file is your application's entrypoint. You provide this information with the Main-Class header in themanifest, which has the general form:

Main-Class: classname The value classname is the name of the classthat is your application's entry point.

Recall that the entry point is a class having a method with signaturepublic static void main(String[] args).

After you have set the Main-Class header in the manifest, you then runthe JAR file using the following form of the java command:

java -jar JAR-name The main method of the class specified in theMain-Class header is executed.

您基本上需要在您的 jar 中有一个 list 文件,并且您需要在其中定义您的 Main-Class 属性:

list 版本:1.0创建者:1.7.0_06(甲骨文公司)主类:fr.srd.remap.compiler.main.Main

当您使用以下命令运行 JAR 文件时,Main 的主要方法将执行:

java -jar MyJar.jar

关于java - 无法从 Windows 上的 jar 加载 Main-Class list 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18183782/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com