Learning Class : Packaging Applet in JAR Files and deploying.

So here is the second entry in the learning class!!

Subject : How do you package your applet in a JAR files and deploy it? What are the step that you take to do so?

Description

The step I take to package and deploy an unsigned applet are the following :

  1. I make sure that my code is complete and that there is no bug.
  2. I put all my class files and ressources (images, music) in an empty folder.
  3. I open the command prompt and navigate to this folder.
  4. I type the following command : jar cvf Test.jar *
  5. I make an html page with the following content :
<html> 
 
<head> 
<title>Applet test</title> 
</head> 
 
<body> 
<h2>Applet test</h2> 
 
<applet code = 'basicGame.BasicApplet3' 
    archive = 'Test.jar', 
    width = 800, 
    height = 600 /> 
    
</body> 
 
</html>
  1. I upload both files (“Test.jar” and “AppletTest.html”) on my server using an ftp client (FileZilla in my case)
  2. Here is the result : Applet Test

Notes

These steps don’t work for signed applet.


So how do you guys do it? Any way to make it faster/easier?

Use Ant or Maven.

The applet tag is deprecated in favour of the object tag.
See this for more information: http://www.w3.org/TR/html401/struct/objects.html#edef-APPLET

Also I use netbeans to handle packaging of my projects. All I do is click a button and automatically creates the .jar file and copies the libraries :slight_smile:

I have some problem with the object tag. I made a new html file with the following content but it doesn’t work.

<html> 
 
<head> 
<title>Applet test</title> 
</head> 
 
<body> 
<h2>Applet test</h2> 
 
<OBJECT codetype="application/java"
        classid="java:basicGame.BasicApplet3"
        archive="Test.jar"
        width="800" height="600">
Java applet that draws a moving square.
</OBJECT>    
</body> 
 
</html>

Using netbeans or eclipse is a great idea I should include that.

Ant and Maven seems like great tools when you have a big project but I don’t think they are really usefull when you only have a few class and ressources. Also, I’m not able to talk about them because of my lack of knowledge.

Not sure if changing to the Object tag right now is a good idea. From wikipedia :

[quote]However, despite object being officially a recommended tag, as of 2010, the support of the object tag was not yet consistent among browsers and Sun kept recommending the older applet tag for deploying in multibrowser environments,[21] as it remained the only tag consistently supported by the most popular browsers. To support multiple browsers, the object tag currently requires JavaScript (that recognizes the browser and adjusts the tag), usage of additional browser-specific tags or delivering adapted output from the server side. Deprecating applet tag has been criticised.[22] Oracle now provides a maintained JavaScript code [23] to launch applets with cross platform workarounds.
[/quote]

stick with the applet tag as it works everywhere, the object tag is useless, its complicates things and doesn’t work in some browsers (like firefox).

APPLET tag is still (and for long) and IMO the BEST way

IMHHHO : W3C… just recommend you to use new things, not things that are compatible, you know … they just try to force people to conform to their recomendations, but those recommendation are not relevant in real world, this kind of organisaton need a reason to exist but the WEB is self-building…

[quote]Using netbeans or eclipse is a great idea I should include that.
[/quote]
for a simple HelloWorld Applet really ?

EDIT: your sample is nice enought

Using Scar to build signed, packed LWJGL applet JARs and it generates an applet.html file:


build(project);
keystore("keystore", "alias", "pw", "Company", "AppName");
lwjglApplet(project, "keystore", "alias", "pw");

Of course, it is only that simple once you get it working, but I find mucking around with Java code more fun than mucking around Googling for Ant XML tags.