使用清单文件将包打包在jar文件中 [英] packing the packages in a jar file with a manifest file
问题描述
我有4个包,每个包含一些 .class
文件。有一个包含 main
类的包。如何创建一个包含所有文件夹和清单文件的jar文件?
I have 4 packages each containing some .class
files. There is one package that contains main
class. How do i create a jar file packed with all the folders and the manifest file ?
我知道命令 jar cvfm MyJar.jar manifest.txt * .class
,但我不知道用其类文件打包所有文件夹的程序。
I know the command jar cvfm MyJar.jar manifest.txt *.class
, but i don't know the procedure to pack all the folders with their class files.
这是场景:
另外我应该在哪里放置清单
文件?
Also where shall i place the manifest
file ?
推荐答案
假设你的类在com.tst包中 - 在cmd(cd ..)中上升一级并输入以下内容:(在UNIX上使用/)
Suppose your classes were in the package com.tst - go up one level in cmd (cd ..) and type the following : (use / on UNIX)
jar -cf myfile.jar .\com\tst\*\*.class
现在,如果你有一个现有的JAR文件,并且想要提取它,你可以输入以下内容
Now, if you have an existing JAR file, and want to extract it, you'd type the following
jar -xf myfile.jar
清单文件可用于指定jar版本和类路径条目
Manifest file can be used for specifying the jar version and classpath entries
这篇关于使用清单文件将包打包在jar文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!