Java的清单文件的类路径,以及如何确定与迪尔斯 [英] Java Manifest file's class path and how it determines relative dirs

查看:141
本文介绍了Java的清单文件的类路径,以及如何确定与迪尔斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在MANIFEST.MF文件中的类路径确定的相对位置?

How does the Class-path in the MANIFEST.MF file determine the relative location?

1)
说我有一个的lib / somejar.jar内部的JAR一个JAR 和OFC清单文件里面 META-INF / MANIFEST.MF 。我将如何设置类路径....?难道是类路径:LIB / somejar.jar ../的lib / somejar.jar

1) Say I have a JAR with a jar inside lib/somejar.jar and ofc the manifest file is inside META-INF/MANIFEST.MF. How would I set the classpath....? Would it be Class-path: lib/somejar.jar or ../lib/somejar.jar ?

2)
比方说,somejar.jar也有它内部的其他罐子主罐子依赖。当然somejar.jar的也有一个正确设置类路径字段自己的MANIFEST.MF文件。现在让我们接着说,原来主要的jar文件,在运行时,需要访问这些JAR文件中的一个,会是能够所以只要somejar.jar是main.jar文件的类路径呢?或者,由于主缸搞砸相对目录运行'somejar.jar'没有根了?

2) Let's say the somejar.jar also has other jars inside of it that the main jar depends on. And of course somejar.jar also has its own MANIFEST.MF file with a correctly set Class-path field. Now lets then say that the original main jar file, during run-time, needs to access one of those JAR files, will it be able to do so as long as somejar.jar is on main.jar's classpath? Or are the relative directories messed up since the main jar is running 'somejar.jar' isn't the root anymore?

小更新:这都将在网络环境中的应用程序服务器上运行,

minor update: This will all run in a web environment, on an application server.

推荐答案

在做纯香草,你不能有一个JAR内部的JAR。你需要要么把它称为外相对路径在一个与主JAR,的的提取JAR的内容在主JAR。

When doing it "plain vanilla", you can't have a JAR inside a JAR. You need to either put it outside in a known path relative to the main JAR, or extract the JAR's contents in the main JAR.

但由于Eclipse 3.5你可以用一个内置的方法来做到这点。检查第二的库处理的选项,当你选择的导出>运行的JAR文件的。

But since Eclipse 3.5 you can do this with a builtin trick. Check the 2nd Library Handling option when you choose Export > Runnable JAR file.

在选择的套餐需要的库文件在生成JAR 的,那么Eclipse将添加一个特殊的类加载器将执行主类透明之前加载这些JAR的为您服务。它这样做与<帮助href=\"http://mail.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.ui/jar%20in%20jar%20loader/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java?view=co\"相对=nofollow> JarRsrcLoader

When choosing Package required libraries into generated JAR, then Eclipse will add a special classloader which will load those JAR's transparently for you before executing the main class. It's doing that with help of JarRsrcLoader.

这篇关于Java的清单文件的类路径,以及如何确定与迪尔斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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