Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit the .properties file inside a jar without extracting it or changed to .zip format

Tags:

java

I currently involved in a project which requires to load a properties file which is located inside a jar file and i need to edit tat. I have Googled a bit and saw quite a few different ways of achieving this ALL idea says i need to rename it to .zip file and after editing again converted to .jar , but i am not satisfied with that answer because i would like to perform the editing without extracting the jar ...is there any possibility by using command prompt or using some interface.... ANY IDEA FRIENDS

like image 636
BEGINER Avatar asked Dec 12 '13 05:12

BEGINER


Video Answer


4 Answers

JAR files are built on the ZIP file format and have the .jar file extension. you can create or extract JAR files using the jar command that comes with a JDK. You can also use zip tools to do so;

You have to know that JAR files - like any other ZIP files is in compressed format. You cannot update a file inside a zip archive without extracting it and putting it back to the archive,no matter what tool may you use (Zip,WinRar,7-Zip or jar) you are just extracting the file and editing and then putting it back to the archive.The below given answers are also doing that,but the file are being extracted to a temporary directory and you are not seeing it.

like image 180
insomniac Avatar answered Oct 17 '22 19:10

insomniac


If you install 7-zip you should be able to open the jar file directly and drag the properties file out of the archive to the desktop or something. Once there you can open/edit then drag it back to the 7-zip window. That's how I do it.

like image 30
Zeb Barnett Avatar answered Oct 17 '22 21:10

Zeb Barnett


Use 7zip, right click on jar and with 7z say open archive, then go to property file, double click and open file with notepad, edit it and save. Now when you will close 7z console, it will ask "update archive?" Say yes... That's it.

like image 2
dev2d Avatar answered Oct 17 '22 21:10

dev2d


Yes you can, In Centos 7 and the vim version 7.4 you can edit zip or jar files zip whit out unzip. So you execute the next commands and you can edit your properties file.

vim Programm.jar 2

[Then you see a lot of directories, so you go to the specific file you wan edit and push enter then you can edit the file use vim with the vim commands.]

like image 1
Franz Joseph Avatar answered Oct 17 '22 21:10

Franz Joseph