Applet (Basic): how to run two applet in one program?

after runnig below program it giving output: applet xyz is ruunig. i want to run both applet abc and xyz . how i can run both applet? [ Multithreading in applet ]

note: if i set access specifier public to abc class it giving error (abc is public, should be declared in a file named abc.java) any solution please.

Tim Moores

Bartender

Posts: 3137

50

posted 8 months ago

1

The way to run two applets is to put two "applet" tags on the HTML page. Your code should *never* call the constructor, nor should it have the "main" method, since that is used by standalone apps, not applets.

nils roy wrote:after runnig below program it giving output: applet xyz is ruunig. i want to run both applet abc and xyz . how i can run both applet? [ Multithreading in applet ]

Welcome to the Ranch, nils!

That code... it isn't even the way to run one applet. You don't run applets from the main() method from a standalone, but like Tim said you run them from an HTML page. Or at least you used to do that back when browsers still supported applets. If you're learning Java on your own and you've got to a place in your book which talks about applets, I'd suggest just skipping that chapter and going on to the next topic. But if you're enrolled in a course and you can't skip over the applets part, well I don't know. Applets are basically dead now and there's very little reason to learn about them at all any more.

nils roy

Greenhorn

Posts: 3

posted 8 months ago

Thank you for your valuable suggestions.

nils roy

Greenhorn

Posts: 3

posted 8 months ago

Paul ,
yes you are right i am learning java my own.
and

Paul Clapham wrote: Applets are basically dead now and there's very little reason to learn about them at all any more.

so should i move to jframe ??? basically i want to know.. to build window base application which things/topics should i need to learn??