0

I have finished a project - jave applet - for a friend. To run the project I am simply clicking Run Application within eclipse. How do I convert my project into 1 file, such that my friend can simply open that one file and the applet will start?

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Justin
  • 447
  • 4
  • 10
  • 33
  • possible duplicate of [How to distribute Java-based software?](http://stackoverflow.com/questions/4838403/how-to-distribute-java-based-software) – Piotr Praszmo Jan 15 '12 at 22:14
  • Just create a jar file with all your class files and resources. With Eclipse this is done by using the Exporting wizard which you can get via the File - Export menus. Then follow the instructions. – Hovercraft Full Of Eels Jan 15 '12 at 22:15
  • The simplest way is to create `.jar` file and specify class with `main` function in manifest. – Piotr Praszmo Jan 15 '12 at 22:16
  • @Banthar: not a duplicate since this deals with Eclipse. Tags to be added to question. – Hovercraft Full Of Eels Jan 15 '12 at 22:16
  • /Your user would be better served by getting a link to a [JWS](http://stackoverflow.com/tags/java-web-start/info) launch application, rather than a web page with an applet embedded. Note also that applets will work when not in a Jar. – Andrew Thompson Jan 16 '12 at 00:42
  • 1
    @Banthar *"specify class with main function in manifest"* An applet has no 'main' class! – Andrew Thompson Jan 16 '12 at 00:45

3 Answers3

1

just export your project as a jar, either directly through eclipse or by using something like Ant.

Then your friend just puts the following code in their html...

<applet code="yourMainClass.class" archive="yourArchive.jar" codebase="yourCodebase/">
Green Day
  • 654
  • 1
  • 8
  • 17
1

To reiterate, you create a Jar file which is done in Eclipse using the Export wizard. Press the File menu then the Export sub-menu, then follow the instructions:

  • Select Jar them Next
  • Select the needed files and resources, create a Jar file name, then press Next
  • Select options, then Next
  • Select a main class -- I know this is important for a desktop application, but I'm not sure if it's needed for applets.
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • When I click browse on the main class, there are then no options. And if I try to leave this field blank, the jar file does not open. I get the error: Failed to load main-class manifest... How can I get around this? – Justin Jan 19 '12 at 00:18
0

The easiest way is to use eclipse export option. Go to File->Export->Java (from list) -> Runnable JAR File (if you dont have it use JAR File instead)->Choose the project you want -> Choose Destination folder -> Finish.

In the folder you have choosen, will be a .jar file.

noisy cat
  • 2,865
  • 5
  • 33
  • 51