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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With