mb2297
asked on
Eclipse: Export Applet complete with import jars
Hello experts,
I have written a little Java Applet which uses JAI, and I'm trying to export it so I can embed it in a webpage.
Using the File > Export > JAR file option, the exported JAR doesn't contain the neccessary JAI classes. I tried copying them into the JAr manually, but I still get java.lang.NoClassDefFoundE rror: com/sun/media/jai/codec/Se ekableStre am when I try to run the applet
My Applet class is AppFrame, in the package com.matt.ui, and it's exported into DrawingTool.jar. Here's my <applet> tag to embed it into an HTML page:
<APPLET CODE="com.matt.ui.AppFrame .class" WIDTH="100%" archive="DrawingTool.jar" HEIGHT="100%"> </APPLET>
How do I get the Applet to recognise the JAI classes?
Thanks,
Matt.
I have written a little Java Applet which uses JAI, and I'm trying to export it so I can embed it in a webpage.
Using the File > Export > JAR file option, the exported JAR doesn't contain the neccessary JAI classes. I tried copying them into the JAr manually, but I still get java.lang.NoClassDefFoundE
My Applet class is AppFrame, in the package com.matt.ui, and it's exported into DrawingTool.jar. Here's my <applet> tag to embed it into an HTML page:
<APPLET CODE="com.matt.ui.AppFrame
How do I get the Applet to recognise the JAI classes?
Thanks,
Matt.
ASKER
Hmm,
I seem to have had a caching issue. It's working fine now.
Thanks anyway,
Matt.
I seem to have had a caching issue. It's working fine now.
Thanks anyway,
Matt.
ASKER
Actually, I'd still like to know how to include the imported jars in the export from Eclipse.
It must be relatively easy, right?
It must be relatively easy, right?
JAI just needs to be in your classpath and if it isn't it wouldn't stop the main class being found.
Suggest that you check your classpath and command line being used to execute the jar.
If using the -jar option then open it up and have a look at you manifest to check that the main class is being referenced correctly.
Suggest that you check your classpath and command line being used to execute the jar.
If using the -jar option then open it up and have a look at you manifest to check that the main class is being referenced correctly.
ASKER
Bear with me on this one...
The problem is somehow related to Manifest files, I think.
Running this function to load an image from a URL:
protected RenderedImage loadImage(URL image_url) throws Exception {
System.out.println("loadin g image from url: "+image_url);
RenderedImage ret_val = null;
FileCacheSeekableStream in_stream = null;
try {
InputStream input_s = image_url.openStream();
in_stream = new FileCacheSeekableStream(in put_s);
RenderedOp rendered_op = JAI.create("stream", in_stream);
BufferedImage in_image = rendered_op.getAsBufferedI mage();
ret_val = in_image;
} finally {
if (in_stream != null) {
in_stream.close();
}
}
return ret_val;
}
I get this exception:
java.lang.ExceptionInIniti alizerErro r
at com.matt.ilab.image.ImageM anager.loa dImage(Ima geManager. java:148)
at com.matt.ilab.image.ImageM anager.set Image(Imag eManager.j ava:73)
at com.matt.ilab.ui.AppFrame. init(AppFr ame.java:6 7)
at sun.applet.AppletPanel.run (Unknown Source)
at java.lang.Thread.run(Unkno wn Source)
The ExceptionInInitializerErro r is caused by some intitialization inside the Manifest. The problem is happening because I manually created the deployed jar file by copying the required classes into it (and not merging the Manifest information).
How do I get Eclipse (or some other tool) to create me a .jar file which has all the required dependencies and their Manifest information all together?
Thanks,
Matt.
The problem is somehow related to Manifest files, I think.
Running this function to load an image from a URL:
protected RenderedImage loadImage(URL image_url) throws Exception {
System.out.println("loadin
RenderedImage ret_val = null;
FileCacheSeekableStream in_stream = null;
try {
InputStream input_s = image_url.openStream();
in_stream = new FileCacheSeekableStream(in
RenderedOp rendered_op = JAI.create("stream", in_stream);
BufferedImage in_image = rendered_op.getAsBufferedI
ret_val = in_image;
} finally {
if (in_stream != null) {
in_stream.close();
}
}
return ret_val;
}
I get this exception:
java.lang.ExceptionInIniti
at com.matt.ilab.image.ImageM
at com.matt.ilab.image.ImageM
at com.matt.ilab.ui.AppFrame.
at sun.applet.AppletPanel.run
at java.lang.Thread.run(Unkno
The ExceptionInInitializerErro
How do I get Eclipse (or some other tool) to create me a .jar file which has all the required dependencies and their Manifest information all together?
Thanks,
Matt.
ASKER
Ok, I figured this one out.
I was assuming that an <applet> tag could only take a single arguement in it's "archive" property - and therefore i needed to roll all the classes into one jar.
As it turns out you can link the applet to as many jars as you like, and it seems there is no way for eclipse to roll them all into one.
Thanks though,
Matt.
I was assuming that an <applet> tag could only take a single arguement in it's "archive" property - and therefore i needed to roll all the classes into one jar.
As it turns out you can link the applet to as many jars as you like, and it seems there is no way for eclipse to roll them all into one.
Thanks though,
Matt.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please print the entire stack trace.
Regards, Vali