Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Jar a project  with property files in it external to jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Jar a project  with property files in it external to jar" Watch "Jar a project  with property files in it external to jar" New topic
Author

Jar a project with property files in it external to jar

kiran kumar
Greenhorn

Joined: Apr 04, 2006
Posts: 27
I have a java class which reads some properties from a property file(which contains database server urls username and passwords).I want
to jar the class file and give it to the some other project so that they can just change the properties file if needed and use the jar file in their project . When i make the jar file ,i see that the property file is inside the jar file and is not user freindly to modify.
I would appricate if someone could help me to know ,
"How can we make a jar file so that its properties file are exteranal to jar".
Jaime M. Tovar
Ranch Hand

Joined: Mar 28, 2005
Posts: 133
They can put you properties file in their own classpath. You have something like this.
/lib/Class1.class
/lib/Class2.class
/lib/Class3.class
/lib/config.properties

Your clients have something like this.
/new/ClassA.class
/new/ClassB.class

Then you jar all your .class files in lib.jar. (without the config.properties)

So your clients want to use your libraries. They can do something like this.
Import/add to classpath your lib.jar
Add a config.properties to their project so it looks like this:
/new/ClassA.class
/new/ClassB.class
/lib/config.properties

They can now jar their project including .class and .properties into new.jar and deploy both lib.jar and new.jar.

I hope it helps
[ September 25, 2007: Message edited by: Jaime Tovar ]

She will remember your heart when men are fairy tales in books written by rabbits.<br /> As long as there is duct tape... there is also hope.
kiran kumar
Greenhorn

Joined: Apr 04, 2006
Posts: 27
Thanks Jaime Tovar for the reply. I have worked out that in a similar way.

thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Jar a project with property files in it external to jar
 
Similar Threads
Problem while executing jar file
propertiest file and xml file, change after build application
adding a property file to a jar
Properties questions
Defining Ant build.xml java properties files for a run targer