Run Java-applets directly ( without html page )
Asked Answered
A

8

7

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.

Afternoon answered 10/6, 2010 at 6:28 Comment(1)
AppletViewr execute applet ojut of browser but i need to get java applet without html pageAfternoon
S
7

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.

Slater answered 28/1, 2014 at 16:23 Comment(2)
Any idea how to pass <PARAM> values?Ulberto
@KeithTyler combine the above code, which goes in a public static void main(String[] args) with the stub approach from this answer.Hickie
B
5

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.

Blackthorn answered 10/6, 2010 at 6:59 Comment(0)
C
1

Run appletviewer [ options ] urls ...

Documentation

Chessa answered 10/6, 2010 at 6:38 Comment(0)
A
1

Build a subclass, which implements main-method, and call init(), start(), stop(), destroy as needed.

Astraphobia answered 10/6, 2010 at 7:27 Comment(0)
B
1

If you use eclipse: Right-Click on your main java file (the one which extends Applet), select the 'Run As' submenu, and select 'Applet.

Blackmun answered 10/6, 2010 at 22:46 Comment(0)
H
1

Use /*<applet code="java file name " height=150 width=150></applet>*/ before declaring applet class and then compile java program and run applet by using appletviewer it execute perfectly don't require any html file

Hoo answered 20/6, 2014 at 9:27 Comment(0)
W
0

This browser extension works quite well. Supports Chrome and Edge.

https://leaningtech.com/cheerpj-applet-runner/

Woodchuck answered 16/8, 2023 at 7:52 Comment(1)
any affiliation? /help/promotionRefinement
R
-1
<applet code=classname height=200 width=200>

</applet>

Simply write this code in your java program and first run using:

javac classname.java

after

run:appletviewer classname.java
Rafferty answered 28/1, 2014 at 4:52 Comment(1)
Consider avoiding all uppercase, and use code tags where appropriate.Pharisaism

© 2022 - 2024 — McMap. All rights reserved.