Archived

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

[java] running an applet from a jar

This topic is 5896 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

How do you run an applet from a jar? Has anyone done this?

Share on other sites
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 on other sites
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 on other sites
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 on other sites
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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• Forum Statistics

• Total Topics
631434
• Total Posts
3000051
×