无法从应用程序 jar 访问 BouncyCastle jar

发布于 2024-07-14 07:04:06 字数 339 浏览 3 评论 0原文

我已经为我的应用程序制作了 jar 文件。 我的应用程序的类之一使用 BC jar 的 BouncyCastleProvider 类。

我在我的应用程序 jar 所在的同一父文件夹中创建了一个文件夹“lib”。

我已经更改了我的计算机 CLASSPATH 以指向这个新的 lib 文件夹。 但是当我运行我的应用程序时,它给了我 classnotfound 异常。

但是如果我将这个 BC jar 文件复制到我的 jre/lib/ext 中,那么一切都会正常工作。

谁能告诉我需要做什么才能从 lib 目录访问 BC jar 文件?

提前致谢, 杰尼什

I have made jar file for my application. One of the class of my application uses BouncyCastleProvider class of BC jar.

I have created one folder "lib" in the same parent folder where my application jar is residing.

I have changed my machine CLASSPATH to point to this new lib folder. But when I run my application it gives me classnotfound exception.

But if I copy this BC jar file to my jre/lib/ext then everything works fine.

Can anybody tell me what I need to do to access BC jar file from my lib directory?

Thanks in Advance,
Jenish

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

您的 JAR 文件必须设置其 MANIFEST.MF 文件以声明 JAR 的类路径。 #

摘自 Sun 教程 下面,在您的情况下,您只需使 Class-Path 指令指向您的 lib 目录,大概

Class-Path: lib/BouncyCastle.jar

我们想要加载 MyUtils.jar 中的类
进入类路径以供使用
MyJar.jar。 这两个 JAR 文件位于
同一目录。

我们首先创建一个名为
Manifest.txt 包含以下内容
内容:

类路径:MyUtils.jar 

  警告:文本文件必须以换行符或回车符结束。 
  

最后一行将不会被解析
如果它不以新的结束,则正确
换行或回车。

然后我们创建一个名为的 JAR 文件
MyJar.jar 输入以下内容
命令:

jar cfm MyJar.jar Manifest.txt MyPackage/*.class 
  

这会创建带有以下内容的 JAR 文件
清单包含以下内容:

清单版本:1.0 
  类路径:MyUtils.jar 
  创建者:1.6.0(Sun Microsystems Inc.) 
  

MyUtils.jar 中的类现在是
当您加载到类路径中时
运行MyJar.jar。

Your JAR file must have its MANIFEST.MF file set to declare the classpath for the JAR.#

Extract from the Sun Tutorial below, in your case you just need to make the Class-Path directive point to your lib directory, presumably

Class-Path: lib/BouncyCastle.jar

We want to load classes in MyUtils.jar
into the class path for use in
MyJar.jar. These two JAR files are in
the same directory.

We first create a text file named
Manifest.txt with the following
contents:

Class-Path: MyUtils.jar

Warning : The text file must end with a new line or carriage return.

The last line will not be parsed
properly if it does not end with a new
line or carriage return.

We then create a JAR file named
MyJar.jar by entering the following
command:

jar cfm MyJar.jar Manifest.txt MyPackage/*.class

This creates the JAR file with a
manifest with the following contents:

Manifest-Version: 1.0
Class-Path: MyUtils.jar
Created-By: 1.6.0 (Sun Microsystems Inc.)

The classes in MyUtils.jar are now
loaded into the class path when you
run MyJar.jar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文