On Tue, 7 Dec 2004 17:39:26 +0800, James wrote:
> eg.
> c:\myapp\test.class
is 'test.class' in 'myapp' package, or is it in the default package?
> c:\myapp\icon\icon1.gif
> c:\myapp\setting.cfg
>
> when I compile and run test.class
> in coding, I write
> something.setImageIcon(getClass().getResource("/icon1.gif"));
If 'default'. The path to the icon is..
URL url = getClass().getResource("/icon/icon1.gif");
// now TEST the URL!
System.out.println( "icon1 URL: " + url );
something.setImageIcon( url );
> after process something, the program will save the file setting in
> setting.cfg
> something.savefile(new
> File(getClass().getResource("/setting.cfg").toString()));
You cannot save the data back into the class jar, and it it
best *not* to write it in the progtam path but the user's
'user.home' directory..
<http://www.physci.org/codes/javafaq.jsp#path>
> all of this run ok, the image got load up, then when save setting, it got
> write back into setting.cfg file.
>
> Later I group all of this in 1 jar file.
> then when I try the program, it cannot run anymore. something related to
> nullpointerexception.
To expand on what FISH wrote..
<http://www.physci.org/codes/javafaq.jsp#exact>
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane