Article View: borland.public.jbuilder.java.api
Article #1845Re: Proplems addressing the path
From: John McGrath TeamB
Date: Wed, 22 Aug 2001 12:33
Date: Wed, 22 Aug 2001 12:33
45 lines
2729 bytes
2729 bytes
On Tue, 21 Aug 2001 09:46:21 -0700, 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>
It is not very clear from your example what your source and output
paths are set to. The normal way to handle this would be to place the
graphics files in your source tree. They will then be automatically
copied to the output path, and that will be placed on the classpath
when you run your program.
The path you specify to getResource() is relative to the root of the
class tree. If you do not specify a leading "/" on the path, it will
be interpreted relative to the location of the class file for the class
on which you call getResource().
> 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.
If you do not want to do that, then you cannot use that mechanism to
locate the graphics files. The Class getResource() method uses the
ClassLoader to locate the files, which means that it is going to look
for them in the same location where the classes are loaded from.
I suppose you could create a separate parallel directory structure for
your graphics files, and then add the root of that directory structure
to the classpath. I think you will find other things that do not work
very well this way, but it should be possible. I would recommend that
you do things the "normal" way until you really understand all of the
issues.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<MPG.15ed65d7b74fba1d98a554@forums.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!btnet-peer1!btnet!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!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-22 05:42:18 PST From: John McGrath [TeamB] <ng-b@JPMcGrath.net> Newsgroups: borland.public.jbuilder.java.api Subject: Re: Proplems addressing the path Date: Wed, 22 Aug 2001 08:33:55 -0400 Message-ID: <MPG.15ed65d7b74fba1d98a554@forums.borland.com> References: <3b81c0ac_1@dnews> <MPG.15ebdf5ccb2a765f98a53f@forums.borland.com> <3b828120_1@dnews> X-Newsreader: MicroPlanet Gravity v2.30 NNTP-Posting-Host: 209.92.40.60 X-Trace: dnews 998483634 209.92.40.60 (22 Aug 2001 05:33:54 -0700) Lines: 45 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!btnet-peer1!btnet!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews