Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
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
Expert: CEHJ replied at 2024-06-04 14:15:58
:-)
Yes, it's case-sensitive
Author: duncanb7 replied at 2024-06-04 14:14:16
1
Author: duncanb7 replied at 2024-06-04 14:13:40
Yes, it run also in IEwith html.
And other question is the javac Myapplet.jave is different from javac myapplet.java , javac is sentitvie to upper and lower case. It works only for upper case of"M"
THanks
Duncan
Expert: CEHJ replied at 2024-06-04 13:59:51
Oh and then it's
javac Myapplet.java
Accepted Solution
Expert: CEHJ replied at 2024-06-04 13:59:23
125 points GOOD
Rename your java file to Myapplet.java