Article View: borland.public.jbuilder.java.api
Article #1841Re: Proplems addressing the path
From: Rich Wilkman
Date: Tue, 21 Aug 2001 16:13
Date: Tue, 21 Aug 2001 16:13
67 lines
3559 bytes
3559 bytes
Gunter:
Resources (things like images) are loaded relative to the class that
needs them and Java storage is package based. This generally means that
you will store your resources with the class that needs them or in a
directory below.
If it really, really bugs you and you just can't live with the resources
being co-located with the classes then write a helper class that lives
in the package/directory you want to store your images in (say
occproject.ImageHelper.class) and then have all your requests to load
images reference that class via a getImage() method.
The trouble with saying "I don't want to do it the Java way" is that now
you have some extra code to write and maintain and that some of the
little helpers in the IDEs out there will not be able to use your
technique. They'll still generate code "the Java way", etc. and then
you have to go and change it yourself.
-Rich
Gunter Sammet wrote:
>
> "/graphics/openFile.gif" didn't work for the second directory structure:
>
> classes/occsoft/occproject/<class files>
> classes/occsoft/graphics/<graphic files>
>
> occ/classes/occproject/<class files>
> occ/src/graphics/<graphic files>
>
> This "../graphics/openFile.gif" still worked for the first directory
> structure as well.
>
> I don't like having the graphic directory underneath classes . Parallel
> would be fine but then I'm back to the problem of going up 2 directories.
> Here my desired directory structure:
>
> occ/classes/occproject/<class files>
> occ/graphics/<graphic files>
>
> Aby hints? btw, I tried to set the classpath in the project settings to ..
> or . but JBuilder didn't like ii.
> TIA Gunter
>
> "John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message
> news:MPG.15ebdf5ccb2a765f98a53f@forums.borland.com...
> > On Mon, 20 Aug 2001 20:06:18 -0700, Gunter Sammet wrote:
> >
> > > I tried to address the graghic files like this:
> > > ...class.getResource("../../src/graphics/openFile.gif").
> > > Some other tries been: "./../../src/graphics/openFile.gif" and
> > > "..\\..\\srcgraphics\\openFile.gif"
> >
> > try: "/graphics/openFile.gif"
> >
> > This should also work if you package your classes into a JAR file.
> > I do not think that would have worked as you had it originally.
> >
> > --
> > Regards,
> >
> > John McGrath [TeamB]
> >
> > ---------------------------------------------------
> > Before sending me e-mail, please read:
> > http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<3B828896.A62C6FDF@formlessvoid.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed2.earthlink.net!newsfeed.earthlink.net!lsanca1-snf1!news.gtei.net!enterprise!news.xtra.co.nz!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3b81c0ac_1@dnews> <MPG.15ebdf5ccb2a765f98a53f@forums.borland.com> <3b828120_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,dc0611d05c92bdd5 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2001-08-21 09:17:20 PST Message-ID: <3B828896.A62C6FDF@formlessvoid.com> Date: Tue, 21 Aug 2001 09:13:10 -0700 From: Rich Wilkman <richw@formlessvoid.com> X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.api Subject: Re: Proplems addressing the path References: <3b81c0ac_1@dnews> <MPG.15ebdf5ccb2a765f98a53f@forums.borland.com> <3b828120_1@dnews> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 208.236.69.60 X-Trace: dnews 998410395 208.236.69.60 (21 Aug 2001 09:13:15 -0700) Lines: 67 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed2.earthlink.net!newsfeed.earthlink.net!lsanca1-snf1!news.gtei.net!enterprise!news.xtra.co.nz!newsfeeds.ihug.co.nz!ihug.co.nz!dnews