facebook

Reading Jar Files using getResource()

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #243810 Reply

    sdunlop
    Member

    I need my application to be able to get the full path information for a jar file within the MyEclipse Project.

    I have imported the jar (my.jar) as an External Jar file on the Project>Properties>Java Build Path

    URL aURL = this.getClass().getClassLoader().getResource(“my.jar”);

    Yet has returned “null” every single time when I’ve run a Junit Test case to validate this.

    Do you need to do something special for MyEclipse to use the ClassLoader.getResource method to read get URL paths to jar files?

    #243823 Reply

    Kapil Kapre
    Member

    AFAIK, a non-fully qualified path to the jar means that java’s class loader will search for the jar in the same directory as the class file. Try giving a more qualified path to the jar.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Reading Jar Files using getResource()

You must be logged in to post in the forum log in