You Are Here:

Community: Developer Discussion Boards

#1 Old Question read image from jar - NETBEANS - 2008-04-14, 02:30

Join Date: Mar 2008
Posts: 13
js001
Offline
Registered User
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
Reply With Quote

#2 Old Re: read image from jar - NETBEANS - 2008-04-14, 19:43

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
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
Reply With Quote

#3 Old Re: read image from jar - NETBEANS - 2008-04-16, 21:04

Join Date: Mar 2008
Posts: 13
js001
Offline
Registered User
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....
Reply With Quote

#4 Old Re: read image from jar - NETBEANS - 2008-04-16, 21:17

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
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
Reply With Quote

#5 Old Re: read image from jar - NETBEANS - 2008-04-16, 22:19

Join Date: Mar 2008
Posts: 13
js001
Offline
Registered User
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..
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Image - byte[] - String (re)conversion lampz Mobile Java Media (Graphics & Sounds) 1 2008-02-19 12:47
Opening a JPEG Image ummarbhutta Mobile Java Media (Graphics & Sounds) 8 2007-02-15 07:34
Resize Image while read byte manupeco Mobile Java Media (Graphics & Sounds) 1 2007-01-29 17:22
how to cut some part of Image mshouab Mobile Java Media (Graphics & Sounds) 2 2006-08-04 10:05
Image Uploader / Image Downloader / Image Server kehong General Symbian C++ 0 2003-05-12 18:38

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ