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?
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?
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.
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.
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.
I suppose the appletviewer could be an option. It is a utility included in the JDK.
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.