Results 1 to 12 of 12
  1. #1
    TeacherZ is offline Member
    Join Date
    Feb 2017
    Posts
    24
    Rep Power
    0

    Default Applet Won't Execute

    I am teaching myself Java using one of the self-instruction books. In the Introductory chapter, there is a Hello World Applet.
    I have been able to get the code to compile - using Java Editor and the latest version of JDK 1.8. However when I try to write the simple HTML for running this applet, I get the error message cannot load plug in.

    I have tried Baidu, Chrome and Firefox, the code fails to successfully execute.
    Maybe this is more properly an HTML question, but since the book was written in 1996, thats a lot of bits long since passed.
    Am I writing the applet the correct way? THe class file and the html code are both in the same directory...

    Any suggestions are welcome. I'm sure this is simple, but I'm too new to let it be simple...

    Thanks...

    Here is the applet code:

    import java.applet.Applet;
    import java.awt.Graphics;

    class HelloBabyApplet extends java.applet.Applet {

    public void paint(Graphics g) {
    g.drawString("Hello Baby!!", 50, 25);
    }
    }

    Here is the HTML code:
    <HTML>

    <HEAD>
    <TITLE>Great Balls O Fire!</TITLE>
    </HEAD><BODY>
    <P>My first Applet just learned its first words!
    <APPLET CODE=HelloBabyApplet.class WIDTH=150 HEIGHT=25>
    </APPLET>
    </BODY>
    </HTML>

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Applet Won't Execute

    That must be an old book.
    Firstly it is using Applet rather than JApplet, which would have made it dated 10+ years ago.
    Secondly it's using applets, which have been phased out as a security risk. The plugin has been dropped from many browser, for example.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Applet Won't Execute

    Applet plugins are no longer supported by the major Webbrowsers due to security concerns. You could use the appletviewer.exe to just get it launched, but my suggestion is to forget the whole applet API all together because it is a thing of the past. Make your hello world program a desktop program.
    1996 sounds like an old book. Java was in its first steps then and things have developed. There are a lot of good, up to date books on the market.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Applet Won't Execute

    Oh, I missed that it was from 1996.
    That's Java 1.
    We're on Java 8 (and not long until 9) now.
    That's far too old.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    TeacherZ is offline Member
    Join Date
    Feb 2017
    Posts
    24
    Rep Power
    0

    Default Re: Applet Won't Execute

    I am a high school teacher in Thailand. My access to a lot of current computer technology is limited to what I can buy.
    Am I wasting my time learning Java from such an old book? I would like to build some applications for teaching my students.
    I realize I will need to learn Java and any special libraries for doing some graphical programming. While I am not an I need
    it yesterday time schedule (this is Thailand, after all), I would like to get some apps up and running in 4 months or so.

    Any advice you can give me would be welcome.
    Thanks...

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Applet Won't Execute

    What sort of IT background are you coming in from?
    The Oracle Tutorials are OK if you have some grounding in programming.
    A lot of people find they work better as a reference, though, but the Basics section should get you set up at least, and give you a handle on the most commonly used classes.

    If you want graphics then you'll either want Swing or JavaFX. I would, however, leave these until you have got a fair amount of coding under your belt. You need to understand Object Oriented principles to use them properly. And don't use the GUI builder for Swing...not so bad for FX, but the Swing ones are quite complex, and make code that's a pain to follow.

    There is an online course I've seen people post before, from some US University? Maybe someone else here might be able to provide a link?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    TeacherZ is offline Member
    Join Date
    Feb 2017
    Posts
    24
    Rep Power
    0

    Default Re: Applet Won't Execute

    I have a fair amount of (cue the laughter) FORTRAN programming experience. I did that as part of my PhD work.
    So far so good on understanding the OOP side of Java. Three days into learning this and I think I am comfortable with the concept of classes etc.
    Assuming a dedicated (near daily) effort to work on learning Java - more than the 21 theoretical days of the book's title - what time frame is reasonable for reaching a competency with Java and JavaFX? I'm not looking to build video game quality here, I just want some cute
    graphics and easy games (think along the lines of the old game Concentration). I realize this will be work, coding is not easy as I'm not
    a professional. Anyway... Any links to good tutorials and cheap (or free) courses would be very helpful. Thanks again for your helpfulness.

  8. #8
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Applet Won't Execute

    Stanford publishes their complete CS106A course and it comes with all video lectures and downloads, etc. There's a lot of material available.

    There are also some fun tutorials on Youtube available.

    MIT also publishes their course, but the published version is so so.

    What you should do during the next 4 months is probably dependent on where you want to be in 4 months from now and how fast you can get the basics down. Do you want a fancy graphic game like a card game? So, it depends on what the plan is and what your audience will be.

    Internalizing any of the GUI frameworks might fill the 4 month time frame entirely.

    Are you wasting time with a Java book from 1996? Mmmh. Well, some basics have stayed the same. But overall I would say yes. If you google free Java ebooks you will find some basic tutorials.

  9. #9
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Applet Won't Execute

    If your audience will be High School kids you might also think about creating some modifications to Minecraft. There's a solid base of support out there. It is all Java and the kids usually like the program.

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Applet Won't Execute

    The Stanford one is the one I was thinking of.
    I knew someone here would have a link!
    :)

    The JavaFX tutorials and notes are here:
    Client Technologies: Java Platform, Standard Edition (Java SE) 8 Release 8

    If you look at the user interface components part after the basics then do what I do and pick the bits you actually want to use. Which does mean thinking up a simple app to produce. And I do mean simple.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  11. #11
    TeacherZ is offline Member
    Join Date
    Feb 2017
    Posts
    24
    Rep Power
    0

    Default Re: Applet Won't Execute

    Thanks to Toll and Benji2505.
    I really appreciate the helpful comments.
    As I said, I have extensive FORTRAN coding experience. Learning how to do OOP seems the hard bit
    for both Java or any other similar language (C++ etc.). But so far I can wrap my brain about it with little to no problems yet.

    On behalf of all my students, I thank you for the help!

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Applet Won't Execute

    If you have any questions then just ask over in the Java forums (either "New To" or "Advanced").
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 1
    Last Post: 01-08-2013, 07:33 AM
  2. How to execute jsp
    By Ravidasineni1234 in forum Java Software
    Replies: 3
    Last Post: 05-07-2011, 01:01 PM
  3. jar file won't execute.
    By Splat in forum New To Java
    Replies: 5
    Last Post: 10-22-2009, 05:26 AM
  4. cannot execute EJB application.
    By JavaEmpires in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 07-17-2008, 09:53 AM
  5. why does not execute this?
    By aleplgr in forum New To Java
    Replies: 6
    Last Post: 08-01-2007, 11:37 AM

Tags for this Thread

Posting Permissions

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