使用文件夹中的 jar 执行 jar 文件

发布于 2024-12-28 15:32:37 字数 352 浏览 4 评论 0原文

我位于 Windows 环境中的 E:/foo/bar 文件夹内。我有一个 jar 文件,名为 E:/foo/bar/a.jar。 foo/bar 里面还有很多 jar 文件。另外,在 foo/bar 下还有另一个名为 ext 的目录。它还包括很多 jar 文件。

我想运行 a.jar 并将这些 jar 包含在类路径(当前目录和 ext 目录)中。所以我用了这个。

java -jar a.jar -classpath *:/ext/*

这不起作用。我没有在 a.jar 的 MANIFEST.MF 中添加任何条目,认为这将从 -classpath 条目中获取。我在这里做错了什么?

谢谢

I am inside a E:/foo/bar folder inside windows environment. I have a jar file as E:/foo/bar/a.jar. Also inside foo/bar there are lot of jar files. Also under the foo/bar there is another directory called ext. It also includes lot of jar files.

I want to run the a.jar with those jars included in the class path(both current directory and ext directory). So I used this.

java -jar a.jar -classpath *:/ext/*

This didn't work. I didnt add any entries in the MANIFEST.MF in a.jar thinking that this will be fetched from the -classpath entry. What am I doing wrong here?

Thank you

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

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

发布评论

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

评论(1

顾挽 2025-01-04 15:32:37

如果指定了 -jar,则忽略 -classpath 选项。

我可以看到两种可能的行动方案:

  1. 在主 Jar 中放置一个清单,确实指定其他 Jars。
  2. 在运行时指定类路径。
    1. 删除调用的 -jar 选项。
    2. 指定所有依赖的Jars
    3. 将完全限定的类名添加到命令末尾,例如
      java -classpath *:/ext/* com.our.MainClass

The -classpath option is ignored if -jar is specified.

Two possible course of action I can see:

  1. Put a manifest in the main Jar that does specify the other Jars.
  2. Specify the class-path at run-time.
    1. Drop the -jar option of the invocation.
    2. Specify all the dependent Jars
    3. Add the fully qualified class name to the end of the command, something like
      java -classpath *:/ext/* com.our.MainClass
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文