Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
"jar -cvf" to Create a JAR with Files
What is the "jar" command to create a JAR file with a list of files in the current folder?
✍: FYIcenter.com
To create a JAR file with a list of files, you can use the "jar -cvf jarname filenames" command.
For exame, the sesson below creates a new JAR file with all class files in the current folder,
\fyicenter>"%java_home%\bin\jar" -xvf jms.jar \fyicenter>copy javax\jms\*.class . javax\jms\BytesMessage.class javax\jms\Connection.class javax\jms\ConnectionConsumer.class javax\jms\ConnectionFactory.class ... \fyicenter>"%java_home%\bin\jar" -cvf myClass.jar *.class added manifest adding: BytesMessage.class(in = 1202) (out= 494)(deflated 58%) adding: Connection.class(in = 945) (out= 373)(deflated 60%) adding: ConnectionConsumer.class(in = 275) (out= 189)(deflated 31%) adding: ConnectionFactory.class(in = 311) (out= 179)(deflated 42%) ... \fyicenter>del *.class \fyicenter>"%java_home%\bin\jar" -tf myClass.jar META-INF/ META-INF/MANIFEST.MF BytesMessage.class Connection.class ConnectionConsumer.class ConnectionFactory.class ConnectionMetaData.class DeliveryMode.class ...
Note that how the "jar" command automatically added a default a MANIFEST.MF file into the JAR.
By the way, the JVM will not like this JAR file, because classes must be added to the JAR with their package names maintained as folder names. See the next tutorial on how to fix this.
Back to FAQ for JDK JAR (Java ARchive) Tool.
2015-11-07, 4178🔥, 0💬
Popular Posts:
Where Can I see Java Source Code files for Xerces Java 2.11.2? Here are Java Source Code files for X...
HttpComponents Client Source Code Files are provided in the source package file, httpcomponents-clie...
Java Architecture for XML Binding (JAXB) is a Java API that allows Java developers to map Java class...
Apache Commons Lang 3 is the 3rd version of Apache Commons Lang, which provides a host of helper uti...
Apache Ant Source Code Files are inside the Apache Ant source package file like apache-ant-1.10.10-s...