Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: Can't get applet to work on Safari..

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Can't get applet to work on Safari..

    Ok, so I'm new here and kind of new to the whole Java thing but I'm taking a course at school and we learned how to open a Java applet using HTML and a web browser. Now I'm trying to use the Mac's Web Sharing to allow all the computers on my network to view my applet. So far it has worked perfectly. The only problem arises when I try to open up the applet using Safari. Firefox seems to work but Safari doesn't. If you need to see the HTML, here it is:

    <html>
    <p style="text-align: center;">
    <applet code = "Candle.class" width="350" height="200">
    </applet>
    </p>
    </html>

    All that results is a blank page and what seems to be Safari trying to load the applet but never able to. Can anyone help?? It would be much appreciated.
    Last edited by Bertorox; September 18th, 2011 at 10:26 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Can't get applet to work on Safari..

    Is there an error message in the browser's java console?

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Can't get applet to work on Safari..

    I don't know how to access the java console when the page doesn't even load.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Can't get applet to work on Safari..

    Is the plugin installed for that browser?

  5. #5
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: Can't get applet to work on Safari..


  6. The Following User Says Thank You to Sean4u For This Useful Post:

    Norm (September 19th, 2011)

  7. #6
    Junior Member
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Can't get applet to work on Safari..

    Yes, java itself works fine. The plug-ins are up to date and everything.

  8. #7
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: Can't get applet to work on Safari..

    So does the Java console open on your screen when you load a page with an applet in it? If it doesn't you could try starting the Java ControlPanel (on my Ubuntu PC I open a terminal and enter 'ControlPanel' - in exactly that case), going to the 'Advanced' tab, expanding the 'Java console' element and choosing 'Show console'.

    If the Java test applet is working and your own project is not, perhaps it's not a Java plugin issue though. What happens if you try to load the class file directly by entering its URL in the Safari URL bar? For example the Java test applet can be downloaded in Firefox by combining the page URL:
    with the codebase in the applet tag (see the page source)
    codebase="../../applet"
    and the archive name
    TestVM2-test.jar
    to give the URL of the jar file
    Firefox attempts to download the file, explaining that it's a 'Java archive' - so it must at least have read a response header by the time the dialog is shown.

    Can you verify on your Mac that Safari is downloading the class file? I don't know Mac Web Sharing - is there an equivalent to Apache's access_log which tells you what requests clients have made and what the response codes / content lengths were?

  9. #8
    Junior Member
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Can't get applet to work on Safari..

    ok, so i opened the page with the java console and this is what it said:

    load: class Candle.class not found.
    java.lang.ClassNotFoundException: Candle.class
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Ap plet2ClassLoader.java:252)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(P lugin2ClassLoader.java:250)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Pl ugin2ClassLoader.java:180)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Pl ugin2ClassLoader.java:161)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plu gin2ClassLoader.java:687)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Plu gin2Manager.java:3045)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Plugin2Manager.java:1497)
    at java.lang.Thread.run(Thread.java:680)
    Exception: java.lang.ClassNotFoundException: Candle.class

  10. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Can't get applet to work on Safari..

    load: class Candle.class not found.
    The browser is looking for the class: class in the package Candle. It is looking for the file: class.class in the Candle folder. Remove the .class from the code= tag so it looks for the class: Candle
    code= should refer to the class, not the filename

  11. #10
    Junior Member
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Can't get applet to work on Safari..

    Are you saying the html should say:

    HTML Code:
    <applet code = "Candle" width="350" height="200">
    </applet>
    The name of the applet is "Candle" btw.

  12. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Can't get applet to work on Safari..

    What happened when you tried it with only the class name (not the filename)?

Similar Threads

  1. Applet paint program frame work.
    By ShaunB in forum Java Swing Tutorials
    Replies: 4
    Last Post: October 31st, 2012, 08:44 AM
  2. Why does this not work?
    By Spidey1980 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: August 12th, 2011, 09:47 AM
  3. pathSeparatorChar doesn't work
    By ordonezc78 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 19th, 2011, 12:25 PM
  4. home work ..
    By shane1987 in forum Collections and Generics
    Replies: 8
    Last Post: November 16th, 2010, 09:45 AM
  5. Applet paint program frame work.
    By ShaunB in forum Java Code Snippets and Tutorials
    Replies: 3
    Last Post: May 5th, 2010, 06:35 PM

Tags for this Thread