Manifest.mf:引用jar文件中的Main类 [英] Manifest.mf: reference Main-class in jar file

查看:2009
本文介绍了Manifest.mf:引用jar文件中的Main类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个可运行的jar,我的主要类是eclipse的JarRsrcLoader。

I am making a runnable jar where my main class is eclipse's JarRsrcLoader.

这是我的包结构

org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

我的清单

Manifest-Version: 1.0
Rsrc-Class-Path: ./selenium-server-standalone-2.39.0.jar
Class-Path: . 
Rsrc-Main-Class: test.Main
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

我的jar中的目录结构:

And the directory structure within my jar:

当我尝试使用以下命令从命令行运行jar时:

When I try to run the jar from command line using:

java -jar output.jar

我得到:

Error: Could not find or load main class org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

谁能看到我哪里出错了?当我将 org 文件夹放在与 output.jar 相同的目录中时,它运行正常。我希望从jar中找到它,以便没有外部依赖。谢谢

Can anyone see where I am going wrong? When i put the org folder in the same directory as output.jar, it runs fine. I want it to be found from within the jar so that there are no external dependencies. Thanks

UPDATE

类文件在jar中:

推荐答案

虽然很长一段时间回来了,但这对我有用了

Though this was asked long time back, this is what worked for me

尝试创建一个包您的工作区如com.eclipse.jdt.internal.jarinjarloader,并放置所有文件JarRsrcLoader.java,RsrcURLConnection.java,RsrcURLStreamHandler.java和RsrcURLStreamHandlerFactory.java,可以从谷歌下载。
然后编写了Manifest,如图所示

Try creating a package in your workspace like com.eclipse.jdt.internal.jarinjarloader and place all the files JarRsrcLoader.java, RsrcURLConnection.java , RsrcURLStreamHandler.java and RsrcURLStreamHandlerFactory.java which can be downloaded from google. Then wrote the Manifest as shown

 Build-Jdk: 1.7.0_55
    Class-Path: .
    Rsrc-Main-Class: com.abc.Master
    Main-Class: com.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
    Rsrc-Class-Path: ./ lib/xyz.jar 

这篇关于Manifest.mf:引用jar文件中的Main类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆