[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.newcomer] Re: FatJar
|
- From: David Houghton <dfhoughton@xxxxxxxxx>
- Date: Sat, 21 Apr 2007 10:13:34 +0000 (UTC)
- Newsgroups: eclipse.newcomer
- Organization: EclipseCorner
- User-agent: pan 0.120 (Plate of Shrimp)
On Sat, 21 Apr 2007 07:12:42 +0000, Emrah wrote:
> Hi David!
> private JButton open = new JButton("", new ImageIcon("Open.jpg"));
>
>
> I tried to do this:
>
>
> Junk.class.getResourceAsStream("Open.jpg")));
>
> but id didnt work..when I am selecting files for fatjar i cant se any jpg
> files or html files there...what is Export Ant doing??is it not an easier
> way to select jpg and html files into the jar file i create?
Fat Jar will by default include all files in the project directory. My
guess is that the resources you want to use are outside this directory. Is
this correct? If so, try moving them in. This directory becomes '/' as far
as locating resources is concerned. Then you can use the technique I first
described:
JButton b = new JButton(new ImageIcon(Junk.class.getResource("/icon.png")));
Note, you're basically always accessing these resources via URL. In the
case of getResourceAsStream you're bypassing one step, but you can get the
contents of a URL by stream, too.