1

I'm facing some trouble to run an applet using appletviewer command line in ms-dos. this is my project tree :

Project
|___classes
|       |___org 
|            |___test
|                  |___Test.class
|
|__src
    |___org       
         |___test
               |___Test.java

Here is Test.java source file :

package org.test;

import java.applet.Applet;

/*<applet code="org.test.Test" width="200" height="100" 
codebase="..\..\..\classes\org\test"></applet>*/

public class Test extends Applet{

    public void init(){

    }

    public void start(){

    }

    public void stop(){

    }

    public void destroy(){

    }

}

I read in an article that the appletviewer only need a file where there is an applet tag inside it, so that it will parse that file to retrieve the tag. That is what I did with the commented line in the source file above.

The source file compiles without any error. Then I try to run it. So I go into the folder where my source file is, and I try this :

prompt\Project\src\org\test>appletviewer Test.java

Here is the error that occurs :

java.lang.ClassNotFoundException: org.test.Test at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:211) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:144) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:662) at sun.applet.AppletPanel.createApplet(AppletPanel.java:785) at sun.applet.AppletPanel.runLoader(AppletPanel.java:714) at sun.applet.AppletPanel.run(AppletPanel.java:368) at java.lang.Thread.run(Thread.java:662)

I think that the error comes from the first line of my java source file, because when I remove it, all works fine. But I just don't know why... Could someone explain me, please?

1 Answer 1

1

I believe it should be

codebase="../../../classes"

And you should be trying to run the .class file, not the .java file, in which case the current directory should be classes when you try to run it.

Sign up to request clarification or add additional context in comments.

3 Comments

Ok, I was just starting to get crazy!! Thank you very much! I now understand.
"..\..\..\classes" should be "../../../classes"
@AndrewThompson : It seems like both notations (\ and /) work fine. I tried them both.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.