如何用包结构创建jar文件? [英] How to create jar file with package structure?

查看:82
本文介绍了如何用包结构创建jar文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件夹结构

/com/cdy/ws/a.class files
/com/cdy/ws/b.class files
/com/cdy/ws/c.class files



<当我运行以下命令jar cvf asd.jar * .class时,它会给jar提供所有类文件。
但是没有生成文件夹结构。所有类文件都必须在com.cdy / ws下,但所有类都在META-INF的相同级别。
有谁能告诉我生成包结构的命令是什么?

When I run the following command "jar cvf asd.jar *.class" it gives jar with all the class files. But the folder structure is not getting generated. All the class files have to be under "com.cdy/ws" but all the classes are in same level of META-INF. Can anyone tell me what is the command to generate the package structure?

谢谢

推荐答案

您需要开始在文件的 root 处创建JAR。

You need to start creating the JAR at the root of the files.

因此,例如:

jar cvf program.jar -C path/to/classes .

假设路径/到/ classes 包含 com 目录。

仅供参考,这些天大多数人使用<$ c相对不常见$ c> jar 直接命令,因为他们将使用构建工具,如 Ant Maven 来处理(以及构建的其他方面)。值得努力的是允许其中一个工具处理构建的所有方面,并且使用一个好的IDE来帮助编写 build.xml 更加容易。 (Ant)或 pom.xml (Maven)。

FYI, these days it is relatively uncommon for most people to use the jar command directly, as they will use a build tool such as Ant or Maven to take care of that (and other aspects of the build). It is well worth the effort of allowing one of those tools to take care of all aspects of your build, and it's even easier with a good IDE to help write the build.xml (Ant) or pom.xml (Maven).

这篇关于如何用包结构创建jar文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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