Results 1 to 5 of 5
  1. #1
    Maarten is offline Member
    Join Date
    Dec 2011
    Location
    Utrecht
    Posts
    22
    Rep Power
    0

    Default Make applet run outside editor

    Hello,
    My applet runs in my editor, but it does not work to make it run on a normal web page. This is the HTML file I wrote with a reference to the java applet on my harddrive. It gives an error that it cant find the java file:


    <html>
    <head>
    <title>blackjack</title>

    </head>
    <body>
    <h1>blackjack</h1>
    <hr>
    <applet code="D:/java/mijnprogs/blackjack5.class" width="300" height="300">
    </applet>
    <hr>
    </body>
    </html>


    What am I doing wrong?

  2. #2
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: Make applet run outside editor

    <applet code="D:/java/mijnprogs/blackjack5.class" width="300" height="300">
    I think the issue you are having is the absolute address of "D:/java/mijnprogs/blackjack5.class." Try changing it to something relative like, if the html file is located in the java folder, make the code attribute be mijnprogs/blackjack5.class. That would be my first attempt.
    My API:
    Java Code:
    cat > a.out || cat > main.class

  3. #3
    Maarten is offline Member
    Join Date
    Dec 2011
    Location
    Utrecht
    Posts
    22
    Rep Power
    0

    Default Re: Make applet run outside editor

    Thanks for your reply, a relative reference does indeed work. But isn't there be a possibility for an absolute reference?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: Make applet run outside editor

    Note that the reference needs to be a URL, not a file name; that relative file path also happens to be relative URL but your absolute file path isn't a URL; read the URL class API documentation for details.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Make applet run outside editor

    Look at the HTML doc for the <Applet tag. The code= attribute names the class, not a path. There is another attribute that gives the path to the class file's location. Something like base or code base.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. How to make image invisible and visible in applet
    By KSBeyaz in forum Java Applets
    Replies: 15
    Last Post: 12-04-2011, 05:58 PM
  2. Problem with creating a jar to make a signed applet
    By Reskaillev in forum New To Java
    Replies: 0
    Last Post: 10-04-2011, 10:36 PM
  3. How to make transparent background of an applet
    By liketanglung in forum Java Applets
    Replies: 0
    Last Post: 03-21-2011, 08:07 AM
  4. Code to make an Applet that downloads?
    By Leeky in forum Java Applets
    Replies: 0
    Last Post: 09-05-2009, 10:56 PM
  5. Make java applet a button
    By hervey in forum New To Java
    Replies: 31
    Last Post: 10-30-2008, 05:44 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
  •