File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 and also few config files under my app folder. I have archived them as agent.jar so that compiled classes in package and files under config folder are archived into agent.jar.

Therefore the folder structure is something like following:-

| -> src -> com -> abc ->
| -> config ->

my jvm parameters are like

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

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

Currently jvm is still picking and using 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 "" and not "" ?

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

My Website: [] Cool your mind:[] My 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 "". 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 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

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
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