Results 1 to 16 of 16
Like Tree2Likes
  • 1 Post By DarrylBurke
  • 1 Post By Fubarable

Thread: Error while running simple applet

  1. #1
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Error while running simple applet

    This is my first applet, and here is error message from browser:

    Java Plug-in 10.2.1.255
    Using JRE version 1.7.0_02-b13 Java HotSpot(TM) Client VM
    User home directory = D:\Documents and Settings\Diamond Dragon
    ----------------------------------------------------
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    ----------------------------------------------------

    Html and class files are in the same directory.
    Any help?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: Error while running simple applet

    Where's the error?

    db
    Fubarable likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Re: Error while running simple applet

    Applet won't show in web browser, and clicking on it comes error dialog with this message: LoanApplet (wrong name chapter18/LoanApplet).
    Last edited by diamonddragon; 02-04-2012 at 05:43 AM.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Error while running simple applet

    Can you show the entire error message? Are you trying to run this from the applet viewer of an IDE or from an HTML file? If the latter, can you show that file?

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: Error while running simple applet

    Check that your folder structure matches the package statement and that the class is correctly named (including package path) in the APPLET tag.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Re: Error while running simple applet

    Running from html file.
    This is source of html:
    XML Code:
    <!-- HTML code, this code is separated from the preceding Java code -->
    <html>
      <head>
        <title>Loan Applet</title>
      </head>
      <body>
        This is a loan calculator. Enter your input for interest, year,
        and loan amount. Click the "Compute Payment" button, you will
        get the payment information. <p>
        <applet
          code = "chapter18.LoanApplet.class"
          width = 300
          height = 150
          >
        </applet>
    
      </body>
    </html>
    And error displayed in error dialog box says: chapter18.LoanApplet.class
    And after that, click details for more information, and more informations says:

    Java Plug-in 10.2.1.255
    Using JRE version 1.7.0_02-b13 Java HotSpot(TM) Client VM
    User home directory = D:\Documents and Settings\Diamond Dragon
    ----------------------------------------------------
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    ----------------------------------------------------

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Error while running simple applet

    So the LoanApplet's class's package is chapter18?

  8. #8
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Re: Error while running simple applet

    Yes.

  9. #9
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Re: Error while running simple applet

    But when I put applet source into default package and compile, it it runs fine.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Error while running simple applet

    I wonder if your problem is the location of your html code relative to the location of your java class files. I don't do applets much, but I suspect that your html code is not located at the user directory. You're better off not even dealing with class files directly but instead jar'ing your code and using the jar file instead of class file.

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Error while running simple applet

    Also, do you need to use the codebase attribute?

    But again, I'm no expert in applets, so take my recommendations as from one amateur to another.

  12. #12
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Re: Error while running simple applet

    Quote Originally Posted by Fubarable View Post
    Also, do you need to use the codebase attribute?

    But again, I'm no expert in applets, so take my recommendations as from one amateur to another.
    It works fine when compiled in default package, but in specified package it shows the error, as described above.

    In both case, html and class files are together.
    What I'm doing wrong, that it wont run properly, when compiled in package different than default?

  13. #13
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Error while running simple applet

    Try not placing the HTML and class files together. Try instead to have the HTML file at the "base" of your class, at the directory which holds the chapter18 directory.
    diamonddragon likes this.

  14. #14
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Re: Error while running simple applet

    Quote Originally Posted by Fubarable View Post
    Try not placing the HTML and class files together. Try instead to have the HTML file at the "base" of your class, at the directory which holds the chapter18 directory.
    That works!
    But what's the point?

  15. #15
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Error while running simple applet

    Quote Originally Posted by diamonddragon View Post
    That works!
    But what's the point?
    I'm guessing that you are using an IDE to compile and run your Java code, correct? If you used the command line, you'd see the parallels immediately. To Java the entire package tree is part of the class's identity, and so I guess that this is the "point". The main point though in my mind is to always create jar files for any "production" code, since this issue is moot for jar'd code.

  16. #16
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Re: Error while running simple applet

    Quote Originally Posted by Fubarable View Post
    I'm guessing that you are using an IDE to compile and run your Java code, correct? If you used the command line, you'd see the parallels immediately. To Java the entire package tree is part of the class's identity, and so I guess that this is the "point". The main point though in my mind is to always create jar files for any "production" code, since this issue is moot for jar'd code.
    Yes, it's IDE.

Similar Threads

  1. Replies: 0
    Last Post: 02-02-2012, 07:24 AM
  2. Replies: 7
    Last Post: 12-18-2011, 04:13 AM
  3. Error while Running the Applet from JAR file
    By rameshiit19 in forum Java Applets
    Replies: 0
    Last Post: 07-27-2011, 01:38 PM
  4. Problem Running in Simple JSTL example
    By arpitgadle in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 06-28-2009, 09:19 PM
  5. [SOLVED] Simple Calculator Applet Weird Error
    By sari in forum New To Java
    Replies: 5
    Last Post: 01-28-2009, 04:57 AM

Posting Permissions

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