Results 1 to 4 of 4
  1. #1
    anacapa is offline Member
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Default Adding property or config files to a project

    using eclipse 3.4.1 Ganymede

    want to add property files to the project such as log4.properties and other .properties files. Created a folder config_deploy under the project in project tree. Project is deployed to a geronimo server added to server view, but error says cannot find .property file. What is the proper way to add .properties files to Eclipse?

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    Place your resources (.properties included) in a directory under the src folder. Eclipse will copy this to the bin folder. For example, if your root package name looks like

    src/com/mycompany/thisapplication

    add a directory

    src/com/mycompany/thisapplication/resources

    and put everything in there.

    At this point, everything can be accessed through the application classpath. Do not use absolute path names, but remember to use the full name of the resource, i.e.

    com/mycompany/myapplication/resources/resource.name

    See ResourceBundle.getBundle() for .properties, ClassLoader.getSystemResource() for other resources.

  3. #3
    anacapa is offline Member
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Default

    Thanks for your post!! I moved the .properties file under the src directory and it works! :)

    I have seen people put .properties files in folders outside of source, beneath the project in the project tree. Do you know how this is done?

  4. #4
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    Java doesn't care where you put your .properties file; it just wants a location.

    The reason I said to put it under src is that it becomes part of the project and can always be found using the classpath, including when it's *deployed*.

    If you put the .properties outside the classpath, then you have to find it some other way, which is a problem when you deploy your application.

Similar Threads

  1. Adding existing items to a project
    By Katherine in forum Eclipse
    Replies: 4
    Last Post: 01-20-2009, 05:23 AM
  2. DOAP files (description of a project)
    By turtleboy in forum XML
    Replies: 0
    Last Post: 11-05-2008, 02:54 PM
  3. Eclipse adding $1.class files
    By eboraks in forum Eclipse
    Replies: 1
    Last Post: 11-28-2007, 05:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •