Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Converting Applet to Jar
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Integrate




PostPosted: Wed Jun 11, 2008 8:49 pm   Post subject: Converting Applet to Jar

Hello. I am currently using eclipse. I have an applet that I want to turn into a jar executable. However, when I turn it into a jar and try to run it, it says there is no main program. The problem is that my applet doesn't have a main to start the program. If i add a main that does nothing, then the init() function will not run. Also, there are complications like having to turn everything to static.

Any ideas on how I can make this jar?
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Thu Jun 12, 2008 8:14 am   Post subject: RE:Converting Applet to Jar

Having never made a .jar myself, I could easily be wrong...but don't executable jars require a MANIFEST file to point to their "main" method?
Aziz




PostPosted: Thu Jun 12, 2008 8:38 am   Post subject: RE:Converting Applet to Jar

Smile Let me explain.

First, why do you want an applet as an executable jar, anyways? Applets are for displaying on webpages. They don't have a main method. You'd need to write an application, which has a main method, and that main method does some code that opens up a JFrame.

Eclipse does all the jar stuff for you, but when you double-click/execute a jar, it executes the main-class (calls its main() method). However, applet's don't have a main method. Eclipse likely runs these using the appletviewer.exe java comes with.

Explain your predicatment more.
HellblazerX




PostPosted: Thu Jun 12, 2008 8:40 am   Post subject: Re: Converting Applet to Jar

Applets are designed to run in html files, which means they can't run stand-alone (I might be wrong though). If that's the case, then you'll have to change your program. Depending on how complex your code, it might mean a tiny change, or a complete make-over. It might also be possible to embed the applet inside a JFrame (which can run stand-alone), but I'm not sure how that can be done. Perhaps another member can elaborate on this.
Aziz




PostPosted: Thu Jun 12, 2008 9:10 am   Post subject: RE:Converting Applet to Jar

You can't embed the applet inside a JFrame without more work than it's work. You convert the JApplet to a JPanel though, which is fairly simple. Then that JPanel can be added to a Frame or Applet.

And in the java bin/ directory IIRC there is an "appletviewer.exe" application. This is what most IDE's use to run applets. You can go in command line and type "appletviewer myapplet.jar", or something similar likely. Look it up more.
Integrate




PostPosted: Thu Jun 12, 2008 3:17 pm   Post subject: RE:Converting Applet to Jar

Never mind, I got it to work. Turns it was my double buffering that prevented me from turning my applet to a JFrame. I made a new double buffer and I was then able to convert the applet to a JFrame, add a main, and compile it.

I wanted to make it an executable because of my Menubar. I found out that MenuBar does not work in my browsers (firefox and explorer).
Aziz




PostPosted: Thu Jun 12, 2008 3:47 pm   Post subject: RE:Converting Applet to Jar

Good job. If you care to share the solution code, I'm sure others would benefit from it.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: