How can I update the jndi.properties file?
I want to update thejndi.properties file to change some bootstrap init parameters. However, the file is packaged into theappserv-rt.jar file. Definitely I can extract thejndi.properties file and make the changes. But the problem is how can I repackage the changedjndi.properties file into the appserv-rt.jar file? Any good tools to use?
Hi,
I just chanced upon this thread and would like to offer a solution that worked for me. It might help others who land on this page.
You can use the -u option of the JAR command line utility to update a JAR File.
Usage: jar {ctxu}[vfm0Mi] [jar-file] [manifest-file] [-C dir] files ...
Options:
-c create new archive
-t list table of contents for archive
-x extract named (or all) files from archive
-u update existing archive
-v generate verbose output on standard output
-f specify archive file name
-m include manifest information from specified manifest file
-0 store only; use no ZIP compression
-M do not create a manifest file for the entries
-i generate index information for the specified jar files
-C change to the specified directory and include the following file
Regards,
Sandeep
hai,
i got solution to update .properties file. saw the previous thread posted by sandeep. ya thanks man. itz a useful information.
problem with my requirement was i need to create a property file in which i store database info like ip address,connection string , port number etc. its a standalone application developed using swings. once if i package my application and present it to my client he should be able to change the information stored in property file eg., ip address, database connection string. so after creating an exe i tried to change the properties file and the change was not reflected in my exe. i had to repackage my application.
atlast i found the solution. its simple but since iam a newbie it took time for me to find out. Just create a properties file and store all the info u want in (key,value) pair. then use
FileInputStream to read the values from the properties file.
sample code:
import java.io.*;
import java.util.Properties;
public class PropertiesTest{
public static void main(String[] args){
Properties props=new Properties();
try{
props.load( new FileInputStream(new File("test.properties")));
}catch(IOException ie){
System.out.println("Error reading file");
}
String key = "name";
String val = props.getProperty(key);
System.out.println(val);
}
}
this code works well. even after packaging ur application u can change the contents of the properties file which will be reflected in ur exe cause every time when u run ur exe it reads data from the file. u can save the .properties file in ur classpath or mention the path in which u save.
previously i did a mistake by creating ResourceBundle class and was reading the values from properties file using bundle.getString("Key"). if u use ResourceBundle class it will be packed inside ur jar file so that the changes made to property file after creating exe will not affect it.
check out this link for more info
http://kickjava.com/855.htm
thanua at 2007-7-14 21:36:29 >

hi,
i have same problem i want to update property file existing value..
but your giving code for reading only can give suggestion how to update
values in property file there is setproperty methode but i m unable to use that properly
waiting for your reply..
if u have solution u can mail me at pc_sreenu@yahoo.com
thanx
sreenu
hi,
i have same problem i want to update property file existing value..
but your giving code for reading only can give suggestion how to update
values in property file there is setproperty methode but i m unable to use that properly
waiting for your reply..
if u have solution u can mail me at pc_sreenu@yahoo.com
thanx
sreenu