Results 1 to 10 of 10

Thread: Html

  1. #1

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    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?
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  2. #2
    Does it run in Nutscrape? And do you have Windows XP, because XP doesn't ship with a VM.

  3. #3

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408
    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.
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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>

  5. #5
    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.

  6. #6
    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.

  7. #7
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    plus dont you have to declare the public void init(){} method
    which will be executed when the applet starts?

  8. #8
    Hehe, that could be one reason why it won't start.

  9. #9

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408
    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
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  10. #10
    Addicted Member Mrs Kensington's Avatar
    Join Date
    Sep 2001
    Location
    Dorset, UK
    Posts
    144
    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
  •  



Click Here to Expand Forum to Full Width