I am using your svg eclipse plugin. I was wondering if any of you has
successfully tried to open an svg which is manipulated by a java jar
application. That is the svg has something like this:
File:circle.svg
----------------
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<script type="application/java-archive" xlink:href="SVGApplication.jar" />
<circle id="myclic-circle" cx="25" cy="25" r="25" fill="blue" />
</svg>
File:manifest.mf
--------------------
Manifest-Version: 1.0
Script-Handler: SVGApplication
File: SVGApplication.java
--------------------------
import org.w3c.dom.*;
import org.w3c.dom.events.*;
import org.apache.batik.script.ScriptHandler;
import org.apache.batik.script.Window;
public class SVGApplication implements ScriptHandler, EventListener {
private Document document;
public SVGApplication()
{
System.out.println("In constructor!!!");
}
public void run (final Document document, final Window win) {
System.out.println("In run of the function!!!");
this.document = document;
EventTarget changecolor =
(EventTarget)document.getElementById("myclic-circle");
changecolor.addEventListener("click", this, false);
}
public void handleEvent(Event evt) {
System.out.println("In handleEvent of the function!!!");
Element changecolor = document.getElementById("myclic-circle");
System.out.println("changecolor:" + changecolor);
changecolor.setAttributeNS(null, "fill", "#0F0000");
}
}
Put all of the above 3 files(circle.svg,SVGApplication.java, manifest.mf)
in a folder
To build SVGApplication.jar the commands are:
javac SVGApplication.java
jar cmf manifest.mf SVGApplication.jar *.class
Now if you open the SVG Browser [Squiggle] independently from the command
prompt by typing the following command on a dos box:
java -jar batik-squiggle.jar
The squiggle svg browser will come up as an independent applicaion and when
you open the circle.svg and click on the circle you will see it change its
color from blue to black.
But if you try to open the SVG browser/SVG Editor from the ecliplse IDE i
have the batik-plugin410.zip and batik binaries 1.6 you will see that it
fails to load the Script-Handler class of apache which is implemented by
SVGApplication the main class in the java file SVGApplication.java. The
error it throws is NoClassDefFound
org.apache.batik.script.ScriptHandler and it happens in
h = (ScriptHandler)cll.loadClass(sh).newInstance(); this line belongs to
the file org.apache.batik.bridge.BaseScriptingEnvironment.java
I have a feeling it is some kind of class loader issue and the squiggle
which is the svg browser does load the jar batik-script.jar. If you can
help me or give me some pointer it would be great!
Nobody/Anonymous ( nobody ) - 2007-02-27 21:22
5
Open
None
Nobody/Anonymous
None
None
Public