Results 1 to 4 of 4
  1. #1
    nanaji is offline Member
    Join Date
    May 2008
    Posts
    31
    Rep Power
    0

    Default loading .properties file dynamically

    Hi

    I am using swingapplication framework for the desktop programme. To get the properties we should use resourceMap = org.jdesktop.application.Application.getInstance() .getContext().getResourceMap(com.aob.test.class);

    But the jar classes i am loading dynamically using ClassLoader.

    Can run the class instance, cannot load the property file.

    How to load the property file along with class file.

    If i keep jar file under classpath, it is working fine.

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

    Default

    You're right, keep the JAR in the classpath. That's how the ClassLoader finds the .properties file.

  3. #3
    nanaji is offline Member
    Join Date
    May 2008
    Posts
    31
    Rep Power
    0

    Default

    Thanks for reply. But i don't want to keep the jar under classpath. Bcz i m planning to load the jar classes using dynamic classLoader.

    I will appreciate if you have any idea .


    Thanks
    Nanaji

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

    Default

    ClassLoader only works with the classpath. I don't know how to do this, but it is possible to alter the classpath inside the JVM and to then create a new ClassLoader instance. That is how Web application servers like Tomcat can reload classes for a particular application without affecting the rest of the server.

    In your case, you want to identify a JAR file, modify the classpath so that JAR is on the classpath, and then create a new ClassLoader, using that ClassLoader instance to load the properties and anything else in the JAR. Again, I don't know how to do that. I suggest reading the API carefully and googling.

Similar Threads

  1. Not able to load a properties file
    By Happy9959 in forum New To Java
    Replies: 12
    Last Post: 07-29-2008, 08:15 AM
  2. Dynamically loading the jsp page to the application
    By shekar in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-09-2008, 04:28 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
  •