• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to place properties file in a directory in the classpath ahead of .jar in eclipse?  RSS feed

 
Happy S Singh
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to place `ABC.properties` file in a directory in the classpath ahead of `cmbview81.jar` .

`cmbview81.jar` already has `ABC.properties` file in it. I extracted the file made some changes and made `new ABC.properties` file and now want to set its path ahead of `cmbview81.j`ar file so that application will not point to the file which is in `cmbview81.jar` file.It should use `new ABC.properties` file.

I tried solutions provided here http://stackoverflow.com/questions/11302531/how-to-place-a-file-on-classpath-in-eclipse but didn't work.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just make sure that it's in the classpath before cmbview81.jar. Normally, if Java is looking for a class or resource, it will pick up the first one that it finds in the classpath.

You'll have to take the exact location into account. For example, if the file is in the JAR under a certain directory, for example "/com/myprogram/abc.properties", then the code in the JAR is probably going to look for it in that directory. You'd have to have a directory com/myprogram that contains abc.properties and you'd have to put the base directory (the directory that contains the "com" directory) in the classpath.

But it might not work - it depends on how exactly the code in the JAR file is finding the file abc.properties.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!