Jump to content
  • Advertisement

Archived

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

nonnus29

[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.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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
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
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!