Avatar billede fredand Forsker
27. september 2002 - 10:00 Der er 9 kommentarer og
1 løsning

Applet doesn't start in browser!

Hello!

I got a small applet that will not start running when I try it in my browser.

I can run it with appletviewer but not with my IE 5.0.

This is the HTML-file:
<HTML>
    <HEAD>
    </HEAD>
    <BODY>
        <APPLET CODE="MyApplet5a.class" WIDTH="600" HEIGHT="400" CODEBASE=".">
            <PARAM NAME=parameter1 VALUE="blue">
        </APPLET>

    </BODY>
</HTML>

In the same directory I have put the class file for this java file:

import java.applet.*;
import java.awt.*;

public class MyApplet5a extends Applet
{
    Button myButton = new Button("The button");
    Label myLabel = new Label("Hello world");

    String statusText;

    public MyApplet5a()
    {
        setSize(400, 400);
        setBackground(Color.blue);
        setLayout(null);


        myButton.setLocation(100, 100);
        myButton.setSize(100, 30);

        myLabel.setLocation(100, 200);
        myLabel.setSize(200, 30);

        add(myButton);
        add(myLabel);

        //statusText = getParameter("parameter1");;

        statusText = "Hello";

        //showStatus(statusText);
    }

    public void init()
    {
        MyApplet5a myApplet5a = new MyApplet5a();
    }

}

I have try to open the html-file with open and put it in a IIS and surf to it with localhost bla bla, but nothing happens.

The Javaconsol prints out this message:

Microsoft (R) VM for Java, 5.0 Release 5.0.0.3805
==============================================
?  hjäp
c  rensa
f  kör slutförare
g  samla in skräp
m  minnesanvändning
q  avsluta
t  lista trådar
==============================================
Error loading class: MyApplet5a
java.lang.NoClassDefFoundError
java.lang.ClassNotFoundException: MyApplet5a
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.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)

Best regards

Fredrik
Avatar billede jakoba Nybegynder
27. september 2002 - 10:03 #1
Jeg vil abefale at du fjerner
    CODEBASE="."
eller erstatter den med en fulstændig adresse.
Avatar billede fredand Forsker
27. september 2002 - 10:48 #2
Hello!

Thanks for your answer I tried:
<APPLET CODE="MyApplet5a" WIDTH="600" HEIGHT="400">

I also tried this:
<APPLET CODE="MyApplet5a.class" WIDTH="600" HEIGHT="400">


But I will still not start!

Best regards

Fredrik
Avatar billede jakoba Nybegynder
27. september 2002 - 10:56 #3
prøv:

<APPLET CODE="MyApplet5a" WIDTH="600" HEIGHT="400"
      codebase="http://yourdomain.se/yourfolderwheretheclassis/">

some servers convert all filnames to lowercase, could that be the problem here?
Avatar billede fredand Forsker
27. september 2002 - 11:15 #4
Hello Jakoba!

I tried this:
<APPLET CODE="MyApplet5a.class" WIDTH="400" HEIGHT="400" CODEBASE="http://localhost/applets/">

But nothing happens. The strange thing is that when i enter som other site on the Internet, with applets, they work fine.

But not my own applet, but it work fine with appletviewer.

PS I compile this with SDK 1.4.

Best regards

Fredrik
Avatar billede jakoba Nybegynder
27. september 2002 - 11:21 #5
Er der ikke noget med at IE har stoppet java-supporten ved version 1.3.7?
men det er ren spekulation. vent og se om ikke der kommer et bedre svar.
Avatar billede fredand Forsker
27. september 2002 - 12:31 #6
You was right!

I had to install teh javaplugin from Sun, but I guess that you agree that it was starnge that other applets worked????

Give me an "answer" so I can give you your points!!

Best regards Fredrik
Avatar billede jakoba Nybegynder
27. september 2002 - 12:53 #7
jamen så tak da :-)
Avatar billede =maddog= Nybegynder
27. september 2002 - 13:45 #8
I hate to burst the bubble here, but I was able to run the example perfectly in NS4.7 (Java 1.1) compiled in Java 1.3.
I still suspect that the ClassLoader is somehow unable to index and dynamically load your applet subclass.
Why it suddenly works with a new JVM is beyond me, but remember you must clear the cache of many IE versions (by pressing CTRL+F5) when testing stuff like this to avoid bringing up an old faulty page. Furthermore you MUST close down ALL open browser windows when testing a new compile to shut down the JVM/JRE.
Avatar billede fredand Forsker
27. september 2002 - 14:08 #9
Ok!

Thanks for you comment maddog!

I guess that it is like Jakoba says, Microsoft have lost there license for Java If I'm not wrong informed.

Thanks mates!

Hope to hear from you aagin!

Best regrads from Fredrik
Avatar billede jakoba Nybegynder
27. september 2002 - 14:34 #10
=maddog=  >>  du har ret; men jeg tror ikke du har helt ret. klassen benytter ikke noget java der ikke er supporteret langt tilbage. så den burde sagtens kunne køre på IE.

men når klassen kopileres med java 1.4 kommer det til at stå i klassefilen, og så kan en overforsigtig java-fortolker vælge at sige "den tør jeg ikke binde an med for jeg er kun version 1.3".

mvh JakobA
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester