Creating a jar with JApplet not executing

Hi,

I am using eclipse to write my application and I am having trouble getting my jar file to work. I have had some success with the jar file working when the main class is set to a JFrame, but as soon as I set the main class to a JApplet and export the program as a jar the file will not run - I double click on it and nothing happens!

I have also tried the cmd version of compiling a jar and I get the same results.
I follow these instructions - http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html

Do I need to do something different for a jar that runs as an applet?

Also I was googleing and I found JBuilder - is this for building java applets? If so is it free and should I use it?

Thanks,

waffe  
waffeAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
You can't run an applet in a jar by doubling clicking it under normal circumstances. The jar file must be used in the applet tag in an html page as its archive attribute

e.g.


<applet codebase="." code="a.b.c.YourApplet" archive="your.jar" width="300" height="300">
</applet>
0
 
Mayank SConnect With a Mentor Associate Director - Product EngineeringCommented:
Does the JFrame have a main () method? The JApplet won't be having it. Its supposed to run in an HTML under a browser, for example.
0
 
hoomanvConnect With a Mentor Commented:
> Also I was googleing and I found JBuilder - is this for building java applets? If so is it free and should I use it?
Borland JBuilder is a Java IDE (Integrated Development Environment) like eclipse
it automates the creation and deployments of applications applets midlets servlets etc
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
waffeAuthor Commented:
What is code="a.b.c.YourApplet" supposed to be?
0
 
hoomanvCommented:
YourApplet class resides in package a.b.c
0
 
hoomanvCommented:
means that YourApplet.class file should be loaded from directory a/b/c (directory hierarchy)
0
 
waffeAuthor Commented:
O' - it is the class that has the main method in it?
0
 
objectsConnect With a Mentor Commented:
> but as soon as I set the main class to a JApplet

your main class should still be the class that contains main, which would open a JFrame

> Do I need to do something different for a jar that runs as an applet?

No, you can have both the application and  applet in the same jar.
When double clicked the main would get run, and when run from a web page the applet would get loaded.

0
 
ksivananthConnect With a Mentor Commented:
Nope, it is the class which extends JApplet!

BTW, JBuilder is not free as eclipse!
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> O' - it is the class that has the main method in it?

Like I said before - the applet need not have a main () method. You will typically load it in a web-browser through an HTML page or something which has an <applet> tag as CEHJ has shown.
0
 
waffeAuthor Commented:
Ok - I think I have it now, and a new problem has arrived which you will probably see posted here  :)

Thanks all,

waffe
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.