4 Replies Latest reply: Dec 22, 2012 5:59 AM by Kayaman RSS

    How to menage file and folder

    piratolo
      Hi,
      i'm having problem understanding how to menage file (images, *.wav, etc.) when creating a Jar file.

      At first i couldn't make my class reach those files, but eventually i made it.

      I make it work, putting the forder with the files, in the package where is the class that needs those file.

      Is this the only way to make it work? Can't i store files in a folder placed outside a class package?

      This way works
      src
      |_____package A ----- Class A
      |____ImagesFolder

      This way doens't work
      src
      |_____package A ----- Class A
      |____ImagesFolder
        • 1. Re: How to menage file and folder
          TPD-Opitz
          please read this to learn how to make better postings:
          https://wikis.oracle.com/display/Forums/Forums+FAQ
          piratolo wrote:
          Hi,
          i'm having problem understanding how to menage file (images, *.wav, etc.) when creating a Jar file.

          At first i couldn't make my class reach those files, but eventually i made it.

          I make it work, putting the forder with the files, in the package where is the class that needs those file.

          Is this the only way to make it work? Can't i store files in a folder placed outside a class package?
          This way works
          src
          |_____package A ----- Class A
          |____ImagesFolder
          
          This way doens't work
          src
          |_____package A ----- Class A
          |____ImagesFolder
          to make it work with the second arrangement you have to add a leading <tt>/</tt> to your resouce path or use
          getClass().getClassLoader().getSystemResource()
          bye
          TPD
          • 2. Re: How to menage file and folder
            piratolo
            Thank for your help, now i get it.
            • 3. Re: How to menage file and folder
              aksarben
              So...(I almost regret this before I write it)....

              If you have three files or folders, do you have to "menage à trois"?
              • 4. Re: How to menage file and folder
                Kayaman
                aksarben wrote:
                So...(I almost regret this before I write it)....

                If you have three files or folders, do you have to "menage à trois"?
                Oh you...