Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mysterious NullPointerException

1 view
Skip to first unread message

Brian Chase

unread,
Jan 23, 1997, 3:00:00 AM1/23/97
to

I'm converting a simple applet (which runs fine on my Win95 machine) to
a stand alone application. When I run get:

java.lang.NullPointerException
at java.applet.Applet.getCodeBase(Applet.java:67)
at spots3.init(spots3.java:24)
at spots3.main(spots3.java:15)

Appears to be a problem related to grabbing the jpeg. Here's the main
and init:

public static void main(String args[]) {
Frame f = new Frame("Making Spots Fly");
spots3 mac = new spots3();
mac.init();
mac.start();

f.add("Center", mac);
f.resize(601,349);
f.show();
}

public void init() {
theezx = getImage(getCodeBase(), "images/300ZXRED.JPG");
setBackground(Color.white);
}

If I exclude the picture the app runs fine. Any help?

Thanks,

Brian Chase

j...@jstechno.ch

unread,
Jan 27, 1997, 3:00:00 AM1/27/97
to

Jon Skeet wrote:
[code excerpt omitted]
>
> If you're running it as a stand-alone application, how do you expect
> it to be able to get a code base? It's not downloaded from anywhere!
> Personally, I'd have a static variable somewhere nice and accessible
> which is just a boolean to say whether you're in an applet or not.
> Whenever you need to work out whether to do applet specific stuff
> (eg getCodeBase()), check that variable.

Wouldn't it be better to check getCodeBase()'s (and getAppletContext(),
probably) return value? I don't like redundancy...

Cheers,
Jean-Michel

0 new messages