Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add new java classes to the existing classes in jar file

Tags:

java

jar

I created new modules for software written in java. This software is run from jar file.My classes are extending the classes in this software. I want to write a plugin which adds new classes to the jar file. I know how to extract a jar file to the directory and add them to the jar file using java.util.jar package but as there are a lot of files to extract from the file, is it possible to add new classes without extracting the files to the folder, somehow directly.

like image 531
user1574866 Avatar asked Aug 03 '12 18:08

user1574866


Video Answer


2 Answers

jar uf jar-file input-file(s)

Will allow to add new files/update existing files in jar without extracting.

like image 131
kosa Avatar answered Oct 17 '22 06:10

kosa


You can use the following command

jar uf foo.jar foo.class
like image 26
Bhavik Ambani Avatar answered Oct 17 '22 08:10

Bhavik Ambani