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, 4035🔥, 0💬
Popular Posts:
JDK 17 jdk.localedata.jmod is the JMOD file for JDK 17 Localedata module. JDK 17 Locale Data module ...
What Is mail.jar of JavaMail 1.4.2? I got the JAR file from javamail-1.4.2.zip. mail.jar in javamail...
How to download and install JDK (Java Development Kit) 6? If you want to write Java applications, yo...
JRE 5 sunjce_provider.jar is the JAR file for JRE 5 Sun JCE Provider, which provides implementations...
Smack is an Open Source XMPP (Jabber) client library for instant messaging and presence. A pure Java...