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

Applet NullPointerException while using HashMap

2 views
Skip to first unread message

Harsha P. R.

unread,
Dec 5, 2000, 3:00:00 AM12/5/00
to
Hi

I'm have a very simple applet which creates a Frame window with a Button
on it. Upon each nutton press, a new window is created and added to a
HashMap. This works perfectly fine on my local system. But it fails when
uploaded to a server and loaded from a browser. Here is the url...

http://202.54.39.200/harsha/dwa/DynamicWindowArrayApplet.html

Can any body tell me whats happening?

Regards,
Harsha

This is what the Java console says...
===================================
Netscape:
java.lang.NullPointerException

at java.lang.StringBuffer.append(Compiled Code)

* at
netscape.applet.DerivedAppletFrame$LoadAppletEvent.dispatch(Compiled
Code)

at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled
Code)

at java.awt.EventDispatchThread.run(Compiled Code)

at
netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled
Code)

===================================
IE:
java.lang.InstantiationException: DynamicWindowArrayApplet
at com/ms/applet/BrowserAppletFrame.newInstance
(BrowserAppletFrame.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.run (AppletPanel.java)
at java/lang/Thread.run (Thread.java)
===================================

Kate Wintjen

unread,
Dec 5, 2000, 3:00:00 AM12/5/00
to

Based solely on getting the same error you did (the Netscape
NullPointerException) I'd start things off by putting a try-catch around
wherever you're calling StringBuffer.append (I presume that's being done near
the beginning?). I'm not sure what the error you're getting in IE means. If
the try-catch confirms the NullPointerException at that point, then whatever
you're trying to append would appear to be null & I'd check where it's being
set. That's all I can come up with at this point. Good luck! Maybe someone
else here will be able to help.

Harsha P. R.

unread,
Dec 5, 2000, 3:00:00 AM12/5/00
to
Hi

I fixed the problem. The problem was, the JVM was unable to find the
required classes of the collections frameworks. ie classes in
java.util.*. I compiled the source, one by one and uploaded the class
files to the server, the frame window poped up.

Now I need to do the same for some other awt classes as well. But still
a question remains, why should this happen in the first place? What can
be done, to avoid putting all the required java.* classes on the server?

with regards
Harsha

Harsha P. R.

unread,
Dec 5, 2000, 3:00:00 AM12/5/00
to
> Based solely on getting the same error you did (the Netscape
> NullPointerException)

>I'd start things off by putting a try-catch around

I had tried that. and it dint work. The problem was the JVM was unable
to find the required java.util classes. So I compiled the required java
source files and uploaded them.

Regards,
Harsha

Kate Wintjen

unread,
Dec 5, 2000, 3:00:00 AM12/5/00
to

Ah. That's kinda ridiculous that the JVM couldn't find stuff in that package,
since it's been around for quite some time. (At least that's my impression.)

Kate Wintjen

unread,
Dec 5, 2000, 3:00:00 AM12/5/00
to
That's awful. I can't imagine why the JVM can't find classes in its own basic
classes. I really don't know what to tell you, since you shouldn't have to do
that and yet that's the solution you found. All I can do is sit shaking my
head, totally dumbfounded. Only thing else I can offer is to wish you extreme
good luck & hope you get this answered.

Ravi Krishnaswamy

unread,
Dec 5, 2000, 3:00:00 AM12/5/00
to

Is the JVM you are testing on older than for jdk1.2 ? (e.g. Netscape 4.7
that I have supports jdk1.1.5).
In that case maybe HashMap is not yet supported in that version of the JVM.
But then again, you do point out that it seems to work on your local system
(with the same browser ?) ...

-ravi

"Harsha P. R." <hars...@comatindia.com> wrote in message
news:3A2D021B...@comatindia.com...

ja...@viasafe.com

unread,
Dec 5, 2000, 3:00:00 AM12/5/00
to
This doesn't work on the server because HashMap is a java 1.2 class, which
is unsupported in IE & NS (with the exception of NS6) unless the Java 2
plug-in is installed.

The reason it works on your local system is because when loaded locally, the
browser has permission to access your CLASSPATH variable which more than
likely is pointing to your Java 2 directory. Or you are using a dev tool
which sets the classpath for the browser when loading the applet.

The solution is to require browsers to have the Java 2 plug-in. Or you
could include the required classes in your jar file on the server. This may
or may not solve your problem, because the JVM's for the current browsers
(except NS6) are only Java1.1.x compliant. You will want to make sure you
do proper testing to decide if this will be an issue for you.

I may not be 100% correct, but this is what I was able to determine from my
experience. Hope it helps.

Good Luck,

Jamie


"Harsha P. R." <hars...@comatindia.com> wrote in message

news:3A2CD924...@comatindia.com...

Harsha P. R.

unread,
Dec 7, 2000, 3:00:00 AM12/7/00
to ja...@viasafe.com
Hi Jamie

ja...@viasafe.com wrote:
>
> This doesn't work on the server because HashMap is a java 1.2 class, which
> is unsupported in IE & NS (with the exception of NS6) unless the Java 2
> plug-in is installed.

Yes, HashMap is Java 1.2 class which isnt supported in JVM 1.1.x
compliant browsers. But if we include the required classes, the browser
has to load the new classes right? Now, IE loads the new classes but
netscape does not.

> The solution is to require browsers to have the Java 2 plug-in.

plugin is a very clostly option.

> Or you
> could include the required classes in your jar file on the server.

this dint slove the problem either. May be I have to write my classes

Regards,
Harsha

Harsha P. R.

unread,
Dec 7, 2000, 3:00:00 AM12/7/00
to ja...@viasafe.com

Harsha P. R.

unread,
Dec 7, 2000, 3:00:00 AM12/7/00
to

Harsha P. R.

unread,
Dec 7, 2000, 3:00:00 AM12/7/00
to Ravi Krishnaswamy
Hi Ravi

Ravi Krishnaswamy wrote:
>
> Is the JVM you are testing on older than for jdk1.2 ? (e.g. Netscape 4.7
> that I have supports jdk1.1.5).
> In that case maybe HashMap is not yet supported in that version of the JVM.

Exactly. The collections frameworks is only available in Java since 1.2.
And Netscape 4.7 (which is still widely used here in India) has a JVM
version 1.1.5 and it does not support collections framework.

> But then again, you do point out that it seems to work on your local system
> (with the same browser ?) ...
>
> -ravi

No, the application version of the applet; thats because the classes are
in the CALSSPATH. But I could figure out solution to this problem with
the help if IE running on its older version of MSJVM, which pointed out
exactly the missing classes. Both NS4.7 and IE (with the latest JVM gave
different messages leading to nowhere.

But the problem is not yet over. Now, that I have complied the required
java.util classes and uploaded them, only IE loads the java.util
classes. But Netscape still refuses to load the java.util classes that I
have uploaded. I also tried making a jar file of all the required
classes and still, Netscape does not load the java.util classes in the
jar file.

Any solutions to this problem? If not, the next best solution is to
write my own classes instead of JDK 1.2's collections framework classes,
which is going to take some time :/

I'm sure someone here has also had a similar problem.

Regards,
Harsha


> "Harsha P. R." <hars...@comatindia.com> wrote in message

> news:3A2D021B...@comatindia.com...
> > Hi
> >
> > I fixed the problem. The problem was, the JVM was unable to find the
> > required classes of the collections frameworks. ie classes in
> > java.util.*. I compiled the source, one by one and uploaded the class
> > files to the server, the frame window poped up.
> >
> > Now I need to do the same for some other awt classes as well. But still
> > a question remains, why should this happen in the first place? What can
> > be done, to avoid putting all the required java.* classes on the server?
> >
> > with regards
> > Harsha
> >
> > "Harsha P. R." wrote:
> > >

Harsha P. R.

unread,
Dec 7, 2000, 3:00:00 AM12/7/00
to
0 new messages