Results 1 to 5 of 5
  1. #1
    pgag45 is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default files in project after creating jar

    Hey All,

    Kind of a general java/java IDE question... but I have several text files that I call and read in my program. However, I was curious, when I compile this into a .jar will these files be included? Will my program still "know" where these files are?

    Or will I need to actually install these files somewhere on a user's computer?

    Thanks!

    Paul

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

    Default

    Depends whether you tell your IDE to include them in the jar. If you use the command-line jar program you can include whatever you want - a jar is just a zip file with Java classes in it.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    pgag45 is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default

    Ah I see... thanks OrangeDog! So if I include them while creating the .jar I should be able to use them just like on the machine I developed them on?

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

    Default

    You'll have to use getResource() and getResourceAsStream() instead of File operations in order to access them.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    If you are going to read the same text time in your application each time, you can include them in the jar file. Or else you have to access then externally from your application, may be through a UI component.

Similar Threads

  1. Creating ZIP files
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-03-2008, 05:14 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
  •