Java applet as a standalone Windows application?

I have a Java applet designed to run on Windows only. (It uses a third party COM object, it is not cross-platform.)

Is there a way to run Java applet as a standalone application on Windows?

+2


source to share


5 answers


While you can certainly run it, there are subtle differences between how Java works as an application and how it works as an applet. One starts with the init method, the other starts with the main method, and the relationship of the thread and event queue to start is slightly different.



Here are some docs from Sun on how to do this. If you are using JApplet, things change a little, but the idea is the same.

+5


source


Java applets usually don't have a main method. They rely on launching a web browser.

It is possible, however, that you are creating a new class that has a main method and a simple call to the init () and start () methods of the applet.



You can take a look at this to better understand the lifecycle of applets.

+2


source


I suppose the appletviewer option might be an option. This is a utility included in the JDK .

+2


source


The JDK has an applet appletviewer

. It is not available in the JRE and its behavior may differ slightly from PlugIn.

Applets from WebStart can also be launched if an appropriate JNLP file is provided.

+1


source


If by "applet" you mean a stand-alone shell for a Java program, a simple batch file is sufficient:

@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 curly braces {{...}}

with the appopriate settings for your application. If everything is defined correctly, double-clicking on the package file name in the file explorer window will execute your Java class.

0


source







All Articles