Accessing an external JAR file using Applet
Hi,
I have created an applet as follows.
Quote:
import java.applet.Applet;
import java.awt.Graphics;
public class SampleApplet extends Applet
{
public void paint(Graphics g)
{
String ss;
Sample s=new Sample();
ss=s.test("From Sample Class");
g.drawString(ss, 20,30);
}
}
I have also made it as a JAR using,
Quote:
jar -cf SampleApplet.jar SampleApplet.class
I have created the dependent class as,
Quote:
public class Sample {
public String test(String a)
{
System.out.println(a);
return a;
}
}
I have created the jar of the above class using ,
Quote:
jar -cf Sample.jar Sample.class
I need Sample.jar to be embedded into SampleApplet.jar and want to run "SampleApplet.jar" as stand alone ...
I wrote the HTML code as,
Quote:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Sample Applet</title>
</head>
<body>
<applet name="SampleApplet" code="SampleApplet"></applet>
</body>
</html>
Please help !
Thanks,
Ramesh Jothimani
Re: Accessing an external JAR file using Applet
Quote:
I need Sample.jar to be embedded into SampleApplet.jar and want to run "SampleApplet.jar" as stand alone ...
Can you explain what "embedded" means?
Any file can be added to a jar file. You can add Sample.jar to the SampleApplet.jar file. No idea what good that is, but it can be done.
Quote:
run "SampleApplet.jar" as stand alone
By standalone, I assume you want to execute the program outside of a browser and without HTML.
Set that jar up as an executable jar. It needs a manifest file with a Main-Class: line that points to a class with a main() method.
Re: Accessing an external JAR file using Applet
Quote:
Originally Posted by
Norm
Can you explain what "embedded" means?
Any file can be added to a jar file. You can add Sample.jar to the SampleApplet.jar file. No idea what good that is, but it can be done.
By standalone, I assume you want to execute the program outside of a browser and without HTML.
Set that jar up as an executable jar. It needs a manifest file with a Main-Class: line that points to a class with a main() method.
I need to add Sample.jar in SampleApplet.jar & I meant it as embedded .
Thanks !
Re: Accessing an external JAR file using Applet
Quote:
add Sample.jar in SampleApplet.jar
You can use the jar command will add the Sample.jar file to the SampleApplet.jar
Why do you want to do that? You will not be able to execute class files contained in the Sample.jar file while it is in another jar file.
Re: Accessing an external JAR file using Applet
That was the requirement I got :( Not they have accepted in making two independent jars and is working fine . Thanks !