PleaseHelpMe
PleaseHelpMe

Reputation: 81

Run Java-applets directly ( without html page )

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.

Upvotes: 7

Views: 21673

Answers (8)

tesla
tesla

Reputation: 1248

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

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

Upvotes: 0

JADAV AKASH
JADAV AKASH

Reputation: 9

<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

Upvotes: -1

stacker
stacker

Reputation: 68942

Run appletviewer [ options ] urls ...

Documentation

Upvotes: 1

Pratik M.
Pratik M.

Reputation: 11

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

Upvotes: 1

spgodara
spgodara

Reputation: 1084

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.

Upvotes: 7

Justin
Justin

Reputation: 4477

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

Upvotes: 1

aioobe
aioobe

Reputation: 420921

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.

Upvotes: 5

springfeld
springfeld

Reputation: 89

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

Upvotes: 1

Related Questions