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" Command Syntax Rules
What are syntax rules of the "jar" command? I am confused on how to specify different options, like x, v, f, i, etc.
✍: FYIcenter.com
The "jar" command usage description is difficult to follow. Here are some "jar" command syntax rules that will help you:
1. The usage description given by entering "jar" with no options is missing the "[-Joption]" option at the end. So the full usage description should be:
Usage: jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] files ... [-Joption]
2. The first argument must be a list of option flags with one and only one command option flag, c, t, x, u, or i. Some valid and invalid examples are given below:
Valid jar command syntax: jar tf my.jar jar ft my.jar jar i my.jar jar xvf my.jar jar c my.class > my.jar Invalid jar command syntax: jar f my.jar Missing command option flag jar ftx my.jar Two command option flags
3. The first argument can have zero or some other non-command option flags: v, f, m, 0, M, and e, in any order. Some valid are given below:
Valid jar command syntax: jar tf my.jar jar tfv my.jar jar cfve my.jar Hello Hello.class4. The first argument can have an optional dash "-" prefix. Some valid examples are given below:
Valid jar command syntax: jar tf my.jar jar -tf my.jar jar cfve my.jar Hello Hello.class5. If the first argument is "i" or "-i", no other option flags are allowed in the first argument. And the second argument must be the JAR file name. Some valid examples are given below:
Valid jar command syntax: jar i my.jar jar -i my.jar6. If f, m, and e flags are specified in the first argument, the second and subsequent arguments are interpreted as one argument for each of these flags in the same order.
Some valid and invalid examples are given below:Valid jar command syntax: jar tf my.jar jar cfve my.jar Hello Hello.class jar cfvem my.jar Hello my.mf Hello.class Invalid jar command syntax: jar tf Missing JAR file name for the f flag jar cfvm my.jar Missing Manifest file name for the e flag jar cfvm my.jar Hello.class Hello.class will be interpreted as the Manifest file7. After the first argument and subsequent arguments for f, m, and e flags, additional arguments are interpreted as inputs to c, t, x, u, or i command option. Some valid examples and invalid are given below:
Valid jar command syntax: jar tvf jms.jar javax/jms/XA List all classes starts with "javax/jms/XA" in the JAR file jar xvf jms.jar javax/jms/XA Extract all classes starts with "javax/jms/XA" in the JAR file jar uvf my.jar -C classes . -C bin xyz.class Add all classes from the "classes" folder and "xyz.class" from the "bin" folder to the JAR file Invalid jar command syntax: jar xvf jms.jar -C classes javax/jms/XA -C will be interpreted as the input for the "x" command option Nothing will be extracted.8. As the last argument, the [-Joption] can be specified. Some valid examples are given below:
Valid jar command syntax: jar tvf jms.jar javax/jms/XA -J-Xms2m jar tvf jms.jar -J-Xms2m jar tvf jms.jar -J-Xms1m Valid syntax. But the JVM will reject the -Xms1m option. JVM requires more tham 1MB of memory to startBack to FAQ for JDK JAR (Java ARchive) Tool.
2016-06-03, ∼3073🔥, 0💬
Popular Posts:
What Is js.jar in Rhino JavaScript 1.7R5? js.jar in Rhino JavaScript 1.7R5 is the JAR file for Rhino...
Java Architecture for XML Binding (JAXB) is a Java API that allows Java developers to map Java class...
Apache Log4j 1.2 Bridge allows applications coded to use Log4j 1.2 API to use Log4j 2 instead. Bytec...
commons-net.jar is the bytecode of Apache Commons Net library, which implements the client side of m...
How to download and install ojdbc7.jar for Oracle 12c R1? ojdbc8.jar for Oracle 12c R1 is a Java 7 a...