• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Why comment in applet java program

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello..

i have 2Q's in my mind while studying JAVA APPLET.

Q1) The Q is that in java applet program why we give comment to <applet tag> which is used for HTML ?

example::



Q2) why in applet program we can't have main() method.? what is main reason for that..??

Please tell me.

Thanking you
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amey Ambulgekar wrote:Q2) why in applet program we can't have main() method.? what is main reason for that..??


You can have a main method. It just wont be used as the entry point to the program.
It's a long time since I wrote an applet so I can't remember what the entry point is, but I guess that the reason that it is different to an application entry point is something to do with the way the code is run from the browser.

And can you remove the < > from the title please. It is causing an image to be added instead of the text.
 
Marshal
Posts: 80085
412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have got rid of the image by changing > to &gt; etc., in the title.
 
Amey Ambulgekar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joanne Neal wrote:

Amey Ambulgekar wrote:Q2) why in applet program we can't have main() method.? what is main reason for that..??


You can have a main method. It just wont be used as the entry point to the program.
It's a long time since I wrote an applet so I can't remember what the entry point is, but I guess that the reason that it is different to an application entry point is something to do with the way the code is run from the browser.

And can you remove the < > from the title please. It is causing an image to be added instead of the text.



Sir Joanne Neal,

first of all Thank you for quick reply..

and secondly, i have removed < > tag from my subject..ok..

Now well, i got it that, why we don't use main() method in an applet because, it is executed by Browser right..?

and about Q1 why we give comment in applet java program..? and how its is executed.. and where it is define in java.?

Thank you again...
 
Sheriff
Posts: 22817
132
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amey Ambulgekar wrote:Q1) The Q is that in java applet program why we give comment to <applet tag> which is used for HTML ?


Some programs, like Oracle's own appletviewer, can use those to open the class without needing an HTML document. For instance, if I make your class public (required for appletviewer) and compile it, I can see the applet by just executing appletviewer MyApplet.java.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And as for your first question: Why do you put the Applet tag in a comment in the Java Code:

1- You don't have to do that.

2- One reason you might want to do that is that you can copy the Applet tag code and past it into HTML when you are ready to write the web page where the Applet gets run from.

3- I wouldn't be surprised if some IDEs might be able to find the applet tag in the comment and use it to run tests inside the IDE. But that would be an IDE feature not something that would be needed by the language.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amey Ambulgekar wrote:Sir Joanne Neal


I haven't been knighted (yet) and even if I had I'd be a Dame
 
Campbell Ritchie
Marshal
Posts: 80085
412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
“There isn’t anything like a Dame” . . . and don’t go calling Joanne Sir
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Oracle's own appletviewer


I'll need more time to adjust to saying "Oracle's..." instead of "Sun's"...
 
Amey Ambulgekar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:And as for your first question: Why do you put the Applet tag in a comment in the Java Code:

1- You don't have to do that.

2- One reason you might want to do that is that you can copy the Applet tag code and past it into HTML when you are ready to write the web page where the Applet gets run from.

3- I wouldn't be surprised if some IDEs might be able to find the applet tag in the comment and use it to run tests inside the IDE. But that would be an IDE feature not something that would be needed by the language.



Hello Steve Luke,

Thank you for your reply and i got the answer of that. Thanks again...

but as you said we can write applet tag code in separate HTML file and HTML file will use ".class" of that applet right.?

but if we place ".class" file of that respective applet program in one folder and applet tag code of HTML in another folder . So how linking will take place.? my be by Package or it should be in same folder ..? will it give error about applet java program.. that it is not found or something...

Thanking you..
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can put the applet class file in a different folder than the HTML code. The codebase attribute is a URL to the location where the class files can be found (it acts like the -cp flag for the java launcher. If the applet is in a different folder, then you use the URL to that different folder. Additionally, if your class is in a package then the codebase should be the base of the classpath, and the code attribute should be the fully qualified name (with the .class extension). So if you had an class in package my.package, with the name MyApplet.class, in the relative folder /resources/java/, then your applet tag might look like this:


Read more about the applet tag here: http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#h-13.4
And here: http://docs.oracle.com/javase/7/docs/technotes/guides/plugin/developer_guide/using_tags.html
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic