Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
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 (322)
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, 4517🔥, 0💬
Popular Posts:
What Is mail.jar of JavaMail 1.4.2? I got the JAR file from javamail-1.4.2.zip. mail.jar in javamail...
JAX-RPC is an API for building Web services and clients that used remote procedure calls (RPC) and X...
JDK 11 java.xml.jmod is the JMOD file for JDK 11 XML (eXtensible Markup Language) module. JDK 11 XML...
JDK 11 jdk.javadoc.jmod is the JMOD file for JDK 11 Java Document tool, which can be invoked by the ...
The Apache FontBox library is an open source Java tool to obtain low level information from font fil...