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 -uvf" Command to Replace a File in a JAR
What are "jar" commands to replace 1 class file in a JAR file? I need to modify one class file and put it back to the JAR.
✍: FYIcenter.com
If you have a large JAR file and just want to replace 1 class file with a modified version, you can follow these steps:
1. Get the source code of that 1 class file.
2. Make changes to the source code.
3. Recompile the source code.
4. Update the JAR file with the new class file from the compilation.
See the example session bellow:
\fyicenter>edit Hello.java
class Hello {
public static void main(String[] a) {
System.out.println("Hello new world!");
}
}
\fyicenter>"%java_home%\bin\javac" Hello.java
\fyicenter>"%java_home%\bin\jar" -uvf myNew.jar Hello.class
adding: Hello.class(in = 420) (out= 289)(deflated 31%)
\fyicenter>"%java_home%\bin\java" -cp myNew.jar Hello
Hello new world!
Back to FAQ for JDK JAR (Java ARchive) Tool.
2016-06-13, ≈13🔥, 0💬
Popular Posts:
What Is mail.jar of JavaMail 1.4? I got the JAR file from javamail-1_4.zip. mail.jar in javamail-1_4...
JDK 11 java.sql.jmod is the JMOD file for JDK 11 SQL (Structured Query Language) module. JDK 11 SQL ...
Apache Log4j 1.2 Bridge allows applications coded to use Log4j 1.2 API to use Log4j 2 instead. Bytec...
SLF4J API is a simple API that allows to plug in any desired logging library at deployment time. Her...
How to download and install javamail-1_2.zip? The JavaMail API is a set of abstract APIs that model ...