applet compilation
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: applet compilation

  1. #1
    Join Date
    Apr 2004
    Posts
    3

    applet compilation

    how do you compile an applet?

  2. #2
    Join Date
    Dec 2003
    Location
    Colchester, England
    Posts
    619
    with a java compiler much the same as an application i would think

  3. #3
    Join Date
    Apr 2003
    Location
    Hyderabad,India
    Posts
    486
    only running an applet differs from normal java program

    u can use appletviewer or browser to view applets
    Thanks n Regards
    Harinath Reddy
    Learn Hello World Program
    A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible. There are no prima donnas in engineering. - Freeman Dyson

  4. #4
    Join Date
    Apr 2004
    Location
    India
    Posts
    15

    no special way of compiling

    There's no difference in compiling a applet and any other java program. After all both of 'em are java programs..

    so go on with your > javac xyzapplet.java

    For running the applet u may create a separate html file wih applet tag as follows..

    <applet code="xyzapplet.class" width="500" height="500">
    </applet>

    else u can add the above code in your java file embraced within the comment marks like..

    /*<applet code="yup.class" width="500" height="500">
    </applet>*/

    For running u can either use a browser or appletviewer

  5. #5
    Join Date
    Apr 2004
    Posts
    131
    In order to have an applet complie and be created, you must:

    - Have your class with the main method extend JApplet
    - Have a method public void init() that initializes all your variables

    If you have those two things, then you can make an applet. The init() method is required to override the abstract init() method in JApplet - it is called by Java when your program is first run from the internet or an appletviewer.
    Last edited by Demonpants Software; April 29th, 2004 at 06:43 AM.

  6. #6
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: no special way of compiling

    Originally posted by hari_03
    There's no difference in compiling a applet and any other java program. After all both of 'em are java programs..

    so go on with your > javac xyzapplet.java

    For running the applet u may create a separate html file wih applet tag as follows..

    <applet code="xyzapplet.class" width="500" height="500">
    </applet>

    else u can add the above code in your java file embraced within the comment marks like..

    /*<applet code="yup.class" width="500" height="500">
    </applet>*/

    For running u can either use a browser or appletviewer
    noting, of course, that the applet tag has been deprecated in favour of object or embed. for example html, click the link "JAR Tutorial" in my signature
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  7. #7
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    Originally posted by Demonpants Software
    - Have your main method extend JApplet
    - Have your main class extend JApplet [or Applet]

    - Have a method public void init() that initializes all your variables
    start() stop() and destroy() are all available too.

    init() and destroy() are called when the applet first loads, and when the applet is being removed for sure (e.g. browser is being closed)
    start() and stop() are called each time an applet is to be started or stopped. browsers may choose to stop an applet if the browser window is minimised, for example, and start it when the window is restored

    think of init() as being similar to the "public static void main(String[] argv)" of a normal java program.. it is called by default. difference is, you dont have any arguments.. you must have the applet call getParameter() to read the parameters that were passed to it from the page:

    http://java.sun.com/j2se/1.4.2/docs/...a.lang.String)
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  8. #8
    Join Date
    Apr 2004
    Posts
    131
    Originally posted by cjard
    - Have your main class extend JApplet [or Applet]
    Right, sorry. I meant the class with the main method in it. I'll edit that...

  9. #9
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    i was considering changing the word "main" too, to avoid confusion with the main method.. only thing, is what words are better to describe the loader class, than "the main class"
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  10. #10
    Join Date
    Apr 2004
    Location
    India
    Posts
    15
    noting, of course, that the applet tag has been deprecated in favour of object or embed. for example html, click the link "JAR Tutorial" in my signature
    Thanks cjard.. I was not in good touch with applets.. and i've missed to update myself.. Thanks for alarming me to update..

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center