Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Java-applets directly ( without html page )

Tags:

java

applet

I have a problem.

How i can run my java-applet directly without embedded in my web page?

I know appletViewr can execute applet without a browser but I need to get java applet without html page.

like image 636
PleaseHelpMe Avatar asked Jun 10 '10 06:06

PleaseHelpMe


People also ask

Can Java applets run from a web browser?

Applets are run inside a web browser via the web browser's "Java Plug-in". This "Java Plug-in" provides a "Java Console", for managing the Java Plug-in and the applets.

Can Java applets run on any platform?

Since Java bytecode is cross-platform (or platform independent), Java applets could be executed by clients for many platforms, including Microsoft Windows, FreeBSD, Unix, macOS and Linux.

Can applet run independently?

An applet program is needed to perform small tasks or part of them. It cannot run on its own; it needs JRE to execute. It cannot start on its own, but it can be executed using a Java-enabled web browser.


2 Answers

Use below code with your code, where AppletClass is your Applet class.

AppletClass appletClass = new AppletClass ();

JFrame frame = new JFrame();
frame.setLayout(new GridLayout(1, 1));
frame.add(appletClass );

// Set frame size and other properties
...

// Call applet methods
appletClass .init();
appletClass .start();

frame.setVisible(true);

More customizations can be done as required.

like image 143
spgodara Avatar answered Oct 04 '22 01:10

spgodara


Appletviewer is the way to go, BUT, it still requires a webpage with an applet-tag.

An alternative solution is to write a stub class, with a main method, that instantiates the applet, calls init(), start(), stop() and destroy() as would otherwise have been done by the browser or appletviewer.

like image 30
aioobe Avatar answered Oct 04 '22 02:10

aioobe