packing the packages in a jar file with a manifest file

耗尽温柔 提交于 2019-12-11 05:36:34

问题


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 ?

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.

Here is the scene :

Also where shall i place the manifest file ?


回答1:


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

Now, if you have an existing JAR file, and want to extract it, you'd type the following

jar -xf myfile.jar

Manifest file can be used for specifying the jar version and classpath entries




回答2:


The manifest needs to be placed in the META-INF directory.

Reference: Jar doc



来源:https://stackoverflow.com/questions/9276390/packing-the-packages-in-a-jar-file-with-a-manifest-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!