简体   繁体   English

在可执行jar中使用非可执行jar中的类

[英]Use classes from a non executable jar in an executable jar

I am trying to uses classes from a non executable jar called noexec.jar in an executable jar called exec.jar . 我正在尝试使用来自名为noexec.jar的非可执行jar中的 ,该可执行文件名为exec.jar With no defined manifest in the nonexec jar and a manifest in the exec jar. 在nonexec jar中没有定义的清单,在exec jar中没有清单。 The folder structure where the jars are held look like so. 罐子所在的文件夹结构如下所示。

ROOT
 /lib
 |
  ---nonexec.jar
  ---exec.jar

With the class path defined in the manifest for the executable jar as Class-Path: nonexec.jar such as in this java link . 在清单中为可执行jar的清单中定义的类路径为Class-Path: nonexec.jar例如在此java link中 However every time I run java -jar exec.jar , I get Exception in thread "main" java.lang.NoClassDefFoundError: helper . 但是,每次我运行java -jar exec.jar ,都会Exception in thread "main" java.lang.NoClassDefFoundError: helper获得Exception in thread "main" java.lang.NoClassDefFoundError: helper Does anyone what even though I am including nonexec in my class path why the classes contained within the jar are not being found? 即使有人在我的类路径中包括nonexec,为什么找不到该jar中包含的类,有人吗?

EDIT: This is the manifest file 编辑:这是清单文件

Manifest-Version: 1.0
Class-Path: .
Main-Class: start

Add nonexec.jar to the class path in your manifest, ie nonexec.jar添加到清单中的类路径,即

Manifest-Version: 1.0
Class-Path: nonexec.jar
Main-Class: start

If you just use Class-Path: . 如果您仅使用Class-Path: . the current directory ( . ) is searched for classes. 在当前目录( . )中搜索类。
If you need more than one jar on the class path list them all separated with a space: 如果在类路径上需要多个jar,请将它们全部用空格隔开:

Class-Path: nonexec.jar nonexec2.jar nonexec3.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM