🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #349

Re: Images in Jar Files

#349
From: Paul Furbacher [TeamB]
Date: Thu, 29 Dec 2005 15:25
47 lines
2701 bytes
Salvador Huertas wrote:

> I need include Images in a jar file, I included the files into the
> JBuilder Project but when I rebuild the Jar Archive don't include
> the images. I don't know if I must have another matter for do so.

In some simple tests that I just did in making
an Application JAR, it seems as though there's a
bug in the Make and Rebuild project and archive
functions.  Even though the JPG extension was set
to "Copy" in the list in Project Properties >
Build > Resources, the single JPG I put in the
"src" folder would not copy to the "classes" folder
when making or rebuilding the project.  Nor would
it copy to the Application JAR when making or rebuilding
the archive, even though the node's Properties > Content
setting is "Include all classes and resources".

Only after selecting the <Project Source> node, and
rebuilding it and then rebuilding the archive did
the image file get copied to the archive.

> My second question it's how must I read this image from the code of
> my application java (what path and other related problems ...)

Assuming you are getting the image in a class
called "MyClass", you should be able to use

   MyClass.class.getResource("image.jpg")

(substitute your image's filename).


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://info.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Technical Details
Message-ID: <43b3ff6f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43b264f2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,253089e9388f71a4
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 29 Dec 2005 10:25:23 -0500
From: "Paul Furbacher [TeamB]" <pfurbacher@mac.com>
Organization: Reverse Alchemy, Inc.
User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Images in Jar Files
References: <43b264f2@newsgroups.borland.com>
In-Reply-To: <43b264f2@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.142.194.228
Message-ID: <43b3ff6f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1135869807 69.142.194.228 (29 Dec 2005 07:23:27 -0700)
Lines: 47
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail