|
-
Sep 26th, 2001, 08:25 PM
#1
Thread Starter
Hyperactive Member
Html
I am brand new to java and I am reading the JAVA Tutorial given out by sun. There seems to be a slight problem though.....they give me the famous Hello World demo that looks like this:
Code:
import java.applet.*;
import java.awt.*;
/**
* The HelloWorld class implements an applet that
* simply displays "Hello World!".
*/
public class HelloWorld extends Applet {
public void paint(Graphics g) {
// Display "Hello World!"
g.drawString("Hello world!", 50, 25);
}
}
and then the html doc that should look like this:
Code:
<HTML>
<HEAD>
<TITLE>A Simple Program</TITLE>
</HEAD>
<BODY>
Here is the output of my program:
<APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>
</APPLET>
</BODY>
</HTML>
Now all is said and done and I compile the class file. Now when I run it in applet viewer it runs fine but when I run it in IE I get a grey box and thats it. Now...I have in my IE options the Java Console Enabled and the JIT compiler for vm enabled. Any ideas?
-
Sep 26th, 2001, 09:18 PM
#2
Member
Does it run in Nutscrape? And do you have Windows XP, because XP doesn't ship with a VM.
-
Sep 27th, 2001, 01:18 AM
#3
Thread Starter
Hyperactive Member
what is Nutscrape? I am guessing its Netscape...and I don't know because as you called it nutscrape. I have win 98 and I know I have downloaded the vm from ms update.
-
Sep 27th, 2001, 10:20 AM
#4
Dazed Member
I know next ot nothing about HTML but looking quickly at your HTML code, i think you have tp put the full path of where your class file resides so the browser can find it.
Code:
<APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>
-
Sep 27th, 2001, 10:23 AM
#5
Member
Originally posted by PITBULLCJR
what is Nutscrape? I am guessing its Netscape...and I don't know because as you called it nutscrape. I have win 98 and I know I have downloaded the vm from ms update.
Yeah, Netscape. It's a joke.
-
Sep 27th, 2001, 10:24 AM
#6
Member
Originally posted by Dilenger4
I know next ot nothing about HTML but looking quickly at your HTML code, i think you have tp put the full path of where your class file resides so the browser can find it.
Code:
<APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>
If it is in the same directory, it shouldn't make a difference.
-
Sep 27th, 2001, 10:25 AM
#7
Dazed Member
plus dont you have to declare the public void init(){} method
which will be executed when the applet starts?
-
Sep 27th, 2001, 10:34 AM
#8
Member
Hehe, that could be one reason why it won't start.
-
Sep 27th, 2001, 08:28 PM
#9
Thread Starter
Hyperactive Member
decalare what and where?...I am glad the tutorial told me this....
So how do I get it to show the string in the applet of the html doc?
Oh and they are in the same path so that shouldn't be the prob
-
Oct 8th, 2001, 09:10 AM
#10
Addicted Member
hmmm seemed to run fine when i tried it!
i assume the java file is named "HelloWorld.java" with those exact capitals and lowercases' and thus the class is called "HelloWorld.class".
you don't need to implement init() as hes just extending the class and not implementing an interface (ignore if you don't understand PITBULLCJR)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|