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, 3942🔥, 0💬
Popular Posts:
Snappy-Java is a Java port of the "snappy", a fast C++ compresser/decompresser developed by Google. ...
SLF4J API is a simple API that allows to plug in any desired logging library at deployment time. Her...
JDK 17 jdk.localedata.jmod is the JMOD file for JDK 17 Localedata module. JDK 17 Locale Data module ...
How to download and install JDK (Java Development Kit) 1.4? If you want to write Java applications, ...
JDK 11 jdk.internal.vm.ci.jmod is the JMOD file for JDK 11 Internal VM CI module. JDK 11 Internal VM...