Asked by duncanb7
at 2024-06-04 13:57:14
Point:125 Replies:5 POST_ID:828310USER_ID:11059
Topic:
Java Programming Language;;
I am new to Java and try my first example but it has one error when excute javac complier at
my working dir such as C:myjavajavac hello.java
The error message is as follows
-----------------------------------------------------
hello.java:5: class HelloWorldApplet is public, should be declared in a file named HelloWorldApplet.java
pulic class HwlloWorldApplet extends Applet{
1error,
-------------------------------------------------
And I tried it on IE with hello.html that is also error, probably casued by javac complier error shown above.
I use following the instruction from this link ,
http://www.roseindia.net/java/java-introduction/javatools/java_applet_viewer.shtml
Any idea what is wrong with this simple example? could you help me to try the example at your sides
in order to start my Java programming And I 've already including everthing of JDK command putting
into my path of C: Shell that is no problem, I could run javac, java, appletviewer in every directory of my
PC.
THanks
Duncan
my working dir such as C:myjavajavac hello.java
The error message is as follows
-----------------------------------------------------
hello.java:5: class HelloWorldApplet is public, should be declared in a file named HelloWorldApplet.java
pulic class HwlloWorldApplet extends Applet{
1error,
-------------------------------------------------
And I tried it on IE with hello.html that is also error, probably casued by javac complier error shown above.
I use following the instruction from this link ,
http://www.roseindia.net/java/java-introduction/javatools/java_applet_viewer.shtml
Any idea what is wrong with this simple example? could you help me to try the example at your sides
in order to start my Java programming And I 've already including everthing of JDK command putting
into my path of C: Shell that is no problem, I could run javac, java, appletviewer in every directory of my
PC.
THanks
Duncan
Hello.java
import java.applet.*;
import java.awt.*;
public class Myapplet extends Applet{
String str;
public void init(){
str = "This is my first applet";
}
public void paint(Graphics g){
g.drawString(str, 50,50);
}
}
import java.applet.*;
import java.awt.*;
public class Myapplet extends Applet{
String str;
public void init(){
str = "This is my first applet";
}
public void paint(Graphics g){
g.drawString(str, 50,50);
}
}
Hello.html
HTML>
<BODY>
<applet code="Myapplet",height="200" width="200">
</applet>
</BODY>
</HTML
HTML>
<BODY>
<applet code="Myapplet",height="200" width="200">
</applet>
</BODY>
</HTML