Java Manifest.mf类路径问题 [英] Java Manifest.mf classpath issues

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

问题描述

我一直在尝试运行一个jar文件 - 让我们称之为test.jar - 在Unix系统上使用Sybase jconn3.jar。

I've been trying to run a jar file - let's call it test.jar - that uses the Sybase jconn3.jar on a Unix system.

我有创建了一个MANIFEST.MF文件,其中包含以下内容:

I have created a MANIFEST.MF file that has the following:

Class-Path: $SYBASE/jConnect-6_0/classes/jconn3.jar commons-net-1.3.0.jar

这给出了一个ClassNotFoundError。 $ SYBASE是指向/ opt / sybase13的系统变量;我还尝试了以下内容:

This gives a ClassNotFoundError. $SYBASE is the system variable that points to /opt/sybase13; I've also tried the following:

Class-Path: /opt/sybase13/jConnect-6_0/classes/jconn3.jar commons-net-1.3.0.jar

Class-Path: opt/sybase13/jConnect-6_0/classes/jconn3.jar commons-net-1.3.0.jar

但是,如果我将jconn3.jar文件从$ SYBASE / jConnect-6_0 /类复制到test.jar所在的目录,并更新我的MANIFEST.MF如下:

However, if I copy the jconn3.jar file from the $SYBASE/jConnect-6_0/classes to the same directory as test.jar, and update my MANIFEST.MF to read as follows:

Class-Path: jconn3.jar commons-net-1.3.0.jar

应用程序按预期运行。

现在,我已经能够通过在本地复制它来验证jconn3.jar文件的工作原理;我的MANIFEST.MF文件包含我的Main-Class的路径,因此这里没有问题。

Now, I've been able to verify the jconn3.jar file works by copying it locally; my MANIFEST.MF file includes the path to my Main-Class, so that's not at issue here.

您认为这可能是什么问题?我一直在看这个东西太久了。
谢谢!

What do you think could be the problem? I've been looking at this thing for too long now. Thanks!

推荐答案

类路径中的条目要么与它们所嵌入的JAR相关(您工作的)或URL。要使绝对路径有效,您需要将它们转换为URL,例如

The entries in the class-path are either relative to the JAR in which they are embedded (which you have working) or are URLs. To make your absolute paths work, you'll need to convert them to URLs, e.g.,

file:/ opt / sybase13 / ...

没有使用变量的机制。

虽然JAR规范没有t清楚地说,绝对文件:方案URL在class-path属性中起作用。

Although the JAR specification doesn't say it clearly, absolute file: scheme URLs do work in the class-path attribute.

这篇关于Java Manifest.mf类路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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