Results 1 to 2 of 2

Thread: I need help..

  1. #1
    nickburris is offline Member
    Join Date
    Jan 2011
    Posts
    30
    Rep Power
    0

    Default I need help..

    Whenever I'm following a tutorial, in this case, this one: Reading/Loading an Image (The Java™ Tutorials > 2D Graphics > Working with Images) , when it wants to load an image, the way the tutorials are doing it is they're loading the image from a file on the computer, how can I change the code so that it's loading the image from the actual source? Like, so I can actually pack the image into the JAR, so when I run it on a different computer, it has the image inside the JAR, and it's not trying to get it from the computer..
    Hope that's not too confusing.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    You just need to use relative paths, for example: 'images/someImage.png". If you are using something like netbeans or eclipse, and the 'images' folder is in the project folder and added to the IDE, then when you create a jar from the project, it will be included automatically and work just fine. If you are doing it from scratch, then you need to read the man page for jar - basically there are options that allow you to include files or even specify a special classpath!

Posting Permissions

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