×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    13

    Question read image from jar - NETBEANS

    hi...in my app, i am trying to read some pre-stored images from jar file..I am using netbeans..my questions are:-

    1) i created a folder called "res" and stored all my images in it. Then in my code :-
    Code:
    InputStream is4 = getClass().getResourceAsStream("/res/basic.jpeg");
    The problem is that is4 is giving null here..Its not able to find the ".jpeg" image. I also tried using
    Code:
    Image.createImage("/res/basic.jpeg")
    still, it gave null pointer exception...
    Where exactly can I put my pre-defined imagefiles in jar and in wat location..What are the settings required in netbeans for this apart from adding res folder?

    PS:- I also tried using "/basic.jpeg", "basic.jpeg", "res/basic.jpeg"

    Please help on this

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: read image from jar - NETBEANS

    Have you checked the JAR file that the images really exist in there (inside the res directory)? You could for example open the JAR file using WinZIP (JAR file is basically a Zip file)...

    Hartti

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    13

    Re: read image from jar - NETBEANS

    Hi hartti,
    thanks for the help, but when i untared the jar, I was not able to see any images in it. How do I mention jar file to store images through netbeans.
    I have created res folder, added that as resources in netbeans through project property, but it just doesnt work....

  4. #4
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: read image from jar - NETBEANS

    I just quickly tested this. I was able to add resources to the jar file through Project Properties

    In short...
    In there, go to
    Build -> Libraries & Resources
    click Add Folder... button and select the folder containing the resources

    Hartti

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    13

    Re: read image from jar - NETBEANS

    hi hartti,

    thanks very much for ur help. Well, what I did was that I stored all "jpg" files and was referiing to them as "jpeg" files in my code. Hence it gave me null pointer exception.)

    All I did was as pointed by you, Project->Properties->library and resourcse->Add folder. Here I added res folder wherein I stored my "jpg" files...now i am able to see them...

    thnx once again..

Similar Threads

  1. Image - byte[] - String (re)conversion
    By lampz in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2008-02-19, 11:47
  2. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  3. Resize Image while read byte
    By manupeco in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2007-01-29, 16:22
  4. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  5. Replies: 0
    Last Post: 2003-05-12, 17:38

Posting Permissions

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