Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit the content of an application.properties or application.yml file inside an existing jar on a remote Linux server

Tags:

java

jar

How to edit a property file (like application.properties) inside of an existing jar file on a remote Linux server.

Imagine the jar is located in /home/user/my-spring-boot.jar and I like to change the username inside of application.propertires from

username=foo 

to

username=bar 

How to open the file and change the property?

like image 218
d0x Avatar asked Sep 25 '12 14:09

d0x


People also ask

How do I change the properties of a jar file?

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.

How do I access application Yml properties?

To read from the application. yml or property file : The easiest way to read a value from the property file or yml is to use the spring @value annotation.


1 Answers

A .jar file is simply a .zip file with a different extension, and vim can edit zip files and their contents directly! Simply vim your .jar, use the file navigator to find your properties file and change it. vim will maintain the zip with your edits.

See here for more details.

like image 180
Brian Agnew Avatar answered Sep 29 '22 12:09

Brian Agnew