Results 1 to 4 of 4
  1. #1
    thorne_ is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    Default loading files contained within app jar file

    Hi all,

    I'm writing an application that needs to load certain files based on a parameter passed into it.

    This works fine when testing locally as i just build the uri based on that parameter (eg. "c:/workspace/PARAMETER/allfiles/") and load all files in that location.

    However now i need to deploy the app as a jar file file on a jboss server and am unsure whether i can manipulate the file structure within a jar to achieve the same thing?

    (For anybody interested the files are Drools drl files and each 'list' represents a different rulebase, theoretically there will be unlimited rulebases)

    So can anybody advise me on the best approach to loading a specific list of files within a jar based on a passed in parameter?

    Thanking you

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Use a variety of getResource...() method to load things from the classpath. (preferred)
    Manipulate jars directly using java.util.jar package.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    thorne_ is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    Default

    regarding loading from the classpath - does this just load from the location that the .class object exist in?

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Info on classpath

    When running from jars, there will be at least one ClassLoader that can search from the root of the jar. Most of the time the system class loader will do the job.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

Similar Threads

  1. loading a text file
    By nick2price in forum New To Java
    Replies: 2
    Last Post: 12-24-2008, 12:46 AM
  2. loading flash files in linux
    By rajeshang in forum AWT / Swing
    Replies: 0
    Last Post: 05-31-2008, 01:59 PM
  3. External JavaScript files not loading
    By sajut in forum New To Java
    Replies: 0
    Last Post: 02-15-2008, 05:47 AM
  4. Loading of JSP file failed
    By Heather in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-06-2007, 01:15 AM

Posting Permissions

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