Home  >  Article  >  Web Front-end  >  Beginner to learn java, questions about applet_html/css_WEB-ITnose

Beginner to learn java, questions about applet_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:24:551027browse

A beginner in Java followed the tutorial and wrote an applet program and reported an error when running! The source code is posted below:
HelloWorldApplet.java source code:
import java.applet.*;
import java.awt.*;
public class HelloWorldApplet extends Applet
{
public void paint(Graphics g)
{

g.drawString("Hello World !",10,50);

}
}
FirstApplet.html source code:

The first java Applet program! ! !





The compilation is passed and the HelloWorldApplet.class file is generated, and these three files are in the same directory.


Running appletviewer FirstApplet.html will report: Loading: The class HelloWorldApplet.class cannot be found
I suspect that my path is wrong:
In my environment variable: JAVA_HOME=C:Javajdk1.6.0_22
CLASSPATH=.;%JAVA_HOME%/lib/tools. jar;%JAVA_HOME%/lib/dt.jar;E:Androidapache- tomcat-7.0.26libjsp-api.jar; E:Androidapache-tomcat-7.0.26libservlet-api.jar;%ANT_HOME%/bin
And me The program is placed under:
under E:androidjavaAppletJavaApplet01. It is running incorrectly: adding -debug, -encoding, etc. after appletviewer is incorrect. I am a Java novice. Please tell me the solution!


Reply to discussion (solution)

Brother, did you go to the wrong place?

Brother, did you run into the wrong place?
I also think the path is wrong, how can I change it? Humbly asking for advice?

The current path is not added to CLASSPATH.
How to write the current path in the configuration. I forgot. Check it yourself.

The current path is not added to CLASSPATH.
How to write the current path in the configuration. I forgot. Check it yourself
After adding the java-related CLASSPATH=%JAVA_HOME%/lib/tools.jar;%JAVA_HOME%/lib/dt.jar, add the current path? It doesn’t seem to work after I added it!

This is the html section. Go to the java section and ask.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn