wood burning stoves 2.0*
The moose likes Java in General and the fly likes classpath file pick order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "classpath file pick order" Watch "classpath file pick order" New topic

classpath file pick order

sridhar vedhanabatla

Joined: Feb 21, 2007
Posts: 12

I have a classpath issue. My app folder is C:/agent I have src packages that start with com.abc and also few config files under my app folder. I have archived them as agent.jar so that compiled classes in com.abc package and files under config folder are archived into agent.jar.

Therefore the folder structure is something like following:-

| -> src -> com -> abc -> A.java
| -> config -> resources.properties

my jvm parameters are like

java -Xms800m -Xmx800m -XX:MaxPermSize=256m -XX:+UseParNewGC -classpath C:\agent2\config\res2.properties agent.jar

I want the jvm to pick res2.properties from C:\agent2\config folder instead of the one present in agent.jar file.

Currently jvm is still picking and using resources.properties from C:\agent\config\ only and not from C:\agent2\config folder.

I guess jvm should pick the first file that comes in the classpath and that should override the subsequent files of same name.

Is there anything wrong in above setup? If yes, then where and why?

Advance thanks,
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 917

1. Class path should contain path, not file.
2. How does you code know it has to refer to "res2.properties" and not "resources.properties" ?

If the code is indeed referring to res2.properties, a FileNotFoundException would have occured.

My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
sridhar vedhanabatla

Joined: Feb 21, 2007
Posts: 12
Thanks SF for your reply.

I understand that classpath spec needs to have file-path and not file. It was my mistake to write it that way in forum post.

Actually the second file too is "resources.properties". I mistakenly gave the different name. Infact I want to use a new value from new file instead of old value from config file in the agent.jar file. Thats the reason the filenames in the C:\agent\config folder and C:\agent2\config is same.

Sorry for the confusion.

salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 917

Its ok

We learn only when we make mistakes.

in reply to your new explaination.....

1. Please change the Original message (so that others may able to answer your question too)
2. If the file resources.properties is indeed being supposed to be read from two places, why did you pack it into agent.jar ??
if you do not do so (i havent tried), i guess it would work fine, try it and let me know

wood burning stoves
subject: classpath file pick order
Similar Threads
Ant Undeploy Problem
Unable to access classes in a jar file
Putting un-jarred config files on the manifest classpath
Better idea to put custom properties in struts 1.2
Problem with JDK