This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Java in General and the fly likes finding properties outside jar files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "finding properties outside jar files?" Watch "finding properties outside jar files?" New topic

finding properties outside jar files?

Geoffrey Falk
Ranch Hand

Joined: Aug 17, 2001
Posts: 171
I have packaged my application in a jar file.
The application uses the following code to
read from the properties file:
InputStream propStream =
When I run the application, it cannot find the properties file unless I package it inside the jar file. Is there some way to set my classpath so that it can find the properties file outside of the jar file?

Sun Certified Programmer for the Java 2 Platform
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Well, the way that we do it is - we jar the classes up. Then we create a bat file that explicitely calls the class that has the main in it using the properties file as a parameter
javaw -cp .;app.jar;otherjars; StartThisClass
< end-file>
Then we have the user start the application using an icon pointing at the .bat file
Of course that means that you can not just double click the jar file and expect it to work.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Geoffrey Falk
Ranch Hand

Joined: Aug 17, 2001
Posts: 171
Thanks. But I would rather do it using a classpath that includes the properties file.
I wonder if I am using the wrong ClassLoader?
Secondly, is there a way to set the Classpath in the manifest of the jar file?
Have you checked out Aspose?
subject: finding properties outside jar files?
It's not a secret anymore!