Judah Gabriel Himango
Judah Gabriel Himango

Reputation: 60001

Java applet as stand-alone Windows application?

I have a Java applet that is meant to run only on Windows. (It uses a 3rd party COM object; it is not cross-platform.)

Is there a way to run a Java applet as a stand-alone application on Windows?

Upvotes: 2

Views: 9848

Answers (5)

Tom Hawtin - tackline
Tom Hawtin - tackline

Reputation: 147124

The JDK has an appletviewer applet launcher. It is not available in the JRE and its behaviour may be slightly different from the PlugIn.

Also applets can be run from WebStart if an appropriate JNLP file is provided.

Upvotes: 1

McDowell
McDowell

Reputation: 108859

I suppose the appletviewer could be an option. It is a utility included in the JDK.

Upvotes: 2

OscarRyz
OscarRyz

Reputation: 199205

Java applets usually don't have a main method. They rely on the webbrowser to be launched.

It is possible though that you create a new class which have a main method and simple call the init() and start() method of the applet.

You may take a look at this to understand better the life cycle of the applets.

Upvotes: 2

Yishai
Yishai

Reputation: 91871

Although you can certainly run it, there are subtle differences between how Java runs as an application vs. how it runs as an applet. One starts with an init method, the other starts with a main method, and the threading and event queue relationship to startup are a bit different.

Here is some documentation from Sun on how to do it. If you are using JApplet things change slightly, but the idea is the same.

Upvotes: 5

David R Tribble
David R Tribble

Reputation: 12204

If by "applet" you mean a stand-alone command shell Java program, a simple batch file should suffice:

@rem MyApp.bat
@echo off
set JVM={{path where java.exe is located}}
set FLAGS={{optional JVM flags}}
set JARFILE={{location of your jarfile}}
%JVM%\java %FLAGS% -cp %JARFILE% {{Package}}.{{Class}} {{args...}}

Replace the items enclosed in braces {{...}} with settings appopriate for your application. If everything is defined correctly, double-clicking the batchfile name in a file explorer window will execute your Java class.

Upvotes: 0

Related Questions