www.webdeveloper.com
Results 1 to 9 of 9

Thread: need help to start using applet

  1. #1
    Join Date
    Jun 2006
    Location
    UK
    Posts
    4

    need help to start using applet

    Hi,

    I am new to java applet and got stuck in using it. I am starting with the clock example provied on web. I download the source code and compiled in JDK1.5.0_06 and try to display the applet in IE browser. As I did the web page using NetBean5.5 web application template, the applet class appeared in the classes folder under WEB_INF. The following is the web page script:

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    </head>
    <body>

    <applet codebase="classes" code="Clock.class" height="200" width="200"></applet>

    </body>
    </html>

    When I run the web page, the browser just display a grey blank box and the Java console tells me this error message:

    Microsoft (R) VM for Java, 5.0 Release 5.0.0.3810
    ==============================================
    ? help
    c clear
    f run finalizers
    g garbage collect
    m memory usage
    q quit
    t thread list
    ==============================================
    java.lang.ClassNotFoundException: Clock
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/applet/AppletPanel.securedClassLoad
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.run
    at java/lang/Thread.run

    I have no idea about this. Can anybody help please? Thanks in advance.

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    This clearly means that browser does not know where the Clock.class file is...
    Make sure the html page is in the same location where class file is.
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Jun 2006
    Location
    UK
    Posts
    4
    Actually, I didn't put class file in the same folder of the html file. It is in the subfolder named classes, so I put codebase="classes" in the applet tag.
    Do I have to always put them in the same folder?

  4. #4
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    no..but you will have to make sure that the place where you have put ur file is visible to the web page
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  5. #5
    Join Date
    Jun 2006
    Posts
    58
    If I may... and I'm probably wrong but.....

    <applet codebase="classes" code="Clock.class" height="200"

    I don't believe that this really tells the JVM anything at all about the location of Clock.class. As I understand it, and again, I'm probably wrong, but codebase needs either an actual URL or a relative path. What you are saying here is that the file "Clock.class" is located in the file "classes", which is impossible. It would have to be either....

    codebase="http://www.yoursite.com/classes/"

    or

    codebase="/classes/"

    assuming, of course, that classes is directory inside your root html directory. If not you would need to supply the JVM with the proper navigation.

  6. #6
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    just to make this work for you....
    put ur html page that has applet code in it, in the classes folder,
    put ur applet class file in the same folder
    classes/
    *.html
    *.class
    now in the applet code in the html page change codebase to this
    codebase="."
    and then test ur applet...this will give u what this all about that visibility of class and stuff..:-)
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  7. #7
    Join Date
    Jun 2006
    Location
    UK
    Posts
    4
    I put them in the same folder. It still doesn't work. So I tried to run my applet in Netscape browser and it works fine. It seems something wrong with my IE browser. What can that be? I can run some online applet examples using IE browser but not with my applet.

  8. #8
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123

    First thing u always want to do is make sure that you have the JRE correctly installed from ur browsers...(download it from java site and re-install it)
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  9. #9
    Join Date
    Jun 2006
    Location
    UK
    Posts
    4
    Thanks, Khalid. I re-install the JRE for IE browser and now it works. Thanks a lot for your help.

    Sally

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles