We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


IE4:"load:myclassapplet can't be instantiated!

thibal asked
Medium Priority
Last Modified: 2006-11-17
This is the answer from the browser when I run my applet with Internet Explorer 4.0.
When I run it with Internet Explorer 3.0.2, the answer is : Exception : java.lang NullPointerException.
What method is able to cause this?

There are questions without answer:

I work on a LAN with an NT server, my webs are on the disk "Apps sur 'serveur1'(F:)" from the server and I not sure that it is the same thing that webs on the Internet.

thank you for your help.
Watch Question


Edited text of question

java.lang.NullPointerException mostly occurs when when you try to invoke a method on
an object that has not been instantiated and is actually null, like in the following example:

String aString = null;
String bString =  aString.toUpperCase(); // = null.toUpperCase() -> NullPointerException

Try to find the exact line where the exception occurs and verify with, for example a "if null
print something" that the problem is well as a I describe it. If yes, the question you have
to ask you if "why is this class instance actually null?". If this causes you problems, please
post the relevant piece of code with a pointer to the line and I will give you a more precise


Here is the code of my applet class. You can see the other class (server etc...)on my 2nd question "can't connect to ...".
But I think the problem is not there.
You recently propose me to use 'getDocumentBase()' but I suppose that the applet find this URL but I am not sure that this URL is the server one.

import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import StreamListener;

public class Exemple3 extends Applet
   public static final int Port=1548;
   URL serverURL=getDocumentBase();
   Socket s;
   DataInputStream in;
   PrintStream out;
   TextField inputfield;
   TextArea outputarea;
   StreamListener listener;

   public void init()
   s = new Socket(serverURL.getHost(),Port);
   in = new DataInputStream(s.getInputStream());
   out = new PrintStream(s.getOutputStream());
   inputfield = new TextField();
   outputarea = new TextArea();
   this.setLayout(new BorderLayout());

   listener = new StreamListener(in, outputarea);

   this.showStatus("Connnected to " 
   + s.getInetAddress().getHostName()
   + " : " +s.getPort());
   catch (IOException e)

   public boolean action(Event e, Object what)
  if (e.target==inputfield)
   return true;
   return false;


In the try :
I change in comments lines "s = new socket...", "in = new DataInputStream..."," out = new PrintStream(..)", "this.showStatus...".

The result is the same.  
When I change in comments "URL serverURL=getDocumentBase()", there is no more problem. So I have a correct program which do nothing. Cool!
Unlock this solution and get a sample of our free trial.
(No credit card required)

Comme cela, je crois que ton programme est encore plus cool! :-)


Fontaine, I want the question to be understandable for everyone,
so I try to write it in english.
I will give you the points when I this program will be running.
I had already try what you purpose but of course the URL found is the path of the directory where is the applet etc...
This applet is not really charged from the server because it is a common disk on server for all machine. So I think it is not the same on the Internet.

I have tested the change on my system, and your applet is working just fine. I tested it served
from my Web server. From the local disk, it will indeed not work (like this). If you want to
have it working from the local disk, the best is to turn it in an app. and use the host name
(not the IP otherwise we are one step back) to identify the server. If you need help to go
into this direction, don't hesitate.

Note: Mon commentaire en Francais etais juste un clin d'oeil. Pour une fois que je croise un
francophone sur le Net... :-))


see you Email!


Adjusted points to 65

It is rare to see points increasing just before grading! Thanks.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.