Archived

This topic is now archived and is closed to further replies.

nonnus29

[java] running an applet from a jar

Recommended Posts

LessBread    1415
Hhere are two ways

  
//HTML

<APPLET ARCHIVE=myjar.jar CODE=myapplet.class WIDTH=100% HEIGHT=100%>
<PARAM NAME=myparamname VALUE="my param value">
</APPLET>

// As part of an app:

#define WIN32_LEAN_AND_MEAN
#include <process.h>
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmd) {
_execlp("javaw", "javaw", "-jar", "myjar.jar", 0);
return 0;
}
//lifted from pirate_dau''s example of how to spawn an executable Java jarfile

Share this post


Link to post
Share on other sites
NuffSaid    122
If you''ve got JRE 1.4 installed in your system, in Windows explorer, all you need to do is to click the jar file, and it''ll run as an app.

that''s assuming that programs like PowerArchiver aren''t associated with .jar file types, and that the jar has a Main-Class specified in its manifest.

Share this post


Link to post
Share on other sites
nonnus29    105
Thanks,
so in the HTML code, the main class is specified by CODE so I don''t have to include it in the manifest?

Share this post


Link to post
Share on other sites
NuffSaid    122
Nope. The main class (i.e. a class with a static main method) is only useful for applications, not applets. So if you''re running a jar as an applet, there''s no need to specify the main class in the manifest.

Share this post


Link to post
Share on other sites