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?
I believe it should be
And you should be trying to run the .class file, not the .java file, in which case the current directory should be
classeswhen you try to run it.