Load an Applet from a Jar
Hello
I am trying some applet program in java, I have a small question for you. How to execute an applet contained within an archive that is from the Jar file. I tried different things but I got nothing but was not successful. I think there should be one way to do this. If you have any idea about it then please let me know. Thanks in advance.
Re: Load an Applet from a Jar
Hello,
You can try the following code for doing the same.
Code:
<html> <head> <title> app </ title> </ head> <hr>
<OBJECT
classid = "clsid: 8AD9C840-044E-11D1-B3E9-00805F499D93"
width = "100" height = "50" align = "baseline" codebase = "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab # version = 1,2, 2.0 ">
<PARAM NAME="code" VALUE="app.class">
<PARAM NAME="codebase" VALUE=".">
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2.2">
<PARAM NAME ="archive" VALUE="app.jar">
<COMMENT>
<EMBED type = "application / x-java-applet; version = 1.2.2"
width = "200" height = "200" align = "baseline"
code = "app.class" codebase = "."
archive = "app.jar"
pluginspage = "http://java.sun.com/products/plugin/1.2/plugin-install.html">
<NOEMBED>
</ COMMENT>
No Java 2 support for APPLET!
</ NOEMBED>
</ EMBED>
</ OBJECT>
<hr> </ body> </ html>
Re: Load an Applet from a Jar
Hello,
If you are confused by the huge code above , then you can simply try the following line in your code and the rest should
Here is the line which you have to include in your code.
Code:
<applet name ="app" archive ="app.jar" code ="test.app" width ="200" height ="25"> < be done automatically.
If you need any more information on this then please let us know and we will try to help you out of your problems. Try it and if you get an error then post the error.
Re: Load an Applet from a Jar
Hello,
Even I had the same problem and I also wanted an applet to run from a jar file. In fact I was already like that but the problem lay elsewhere. My build.xml changed somewhat the structure of my package so I did enjoyed my class Applet. So, first see that the class file is not changed by the other things which you are trying to perform in the code. Just be cool while doing the changes to your code because they effect the class file also.
Re: Load an Applet from a Jar
Hello,
The simplest solution (in my opinion) is to build a bat file in which we place orders necessary to save the file in the bin directory of java sdk and run the bat file.
bat file example:
Code:
jar cf march.jar mapp.class
Simply retrieve the archive "march.jar" and place it in the web server directory.
To view the applet in a web page, you place the tags (at least) the following:
Code:
<applet code = "mapp.class" archive = "march.jar" width ="..." height ="..." codebase ="..." name = "mapp"> <param ...> </ applet>
It is no longer necessary to place the file "mappt.class" in the directory of the web server as it will be present in the jar archive. This allows to verify if it works.
Re: applet executable from jar file
Hello,
I tried the same, but I have the problem too. I am trying to load the applet from a jar file but it is not working.
Here is the code
Code:
import javax.swing.*;
import java.applet.Applet;
public class test extends Applet {
/**
*
*/
private static final long serid = 1L;
public void init() {
JOptionPane.showMessageDialog(null, "Hello, World!");
}
}