You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Claire WALL <K9...@atlas.kingston.ac.uk> on 2003/02/24 13:47:27 UTC

importing an SVG graphic into an applet

Hi,

I have successfully managed to import an SVG graphic/file into an 
application but when trying to import an SVG graphic into an applet 
I am having some problems.

Here’s the code for my applet:

import org.apache.batik.swing.*;
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.svggen.*;
import 
org.apache.batik.dom.svg.SVGDOMImplementation;
import org.w3c.dom.*;
import org.w3c.dom.svg.*;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;

public class TestSVGInApplet extends JApplet
{
    
    public void init()
    {
        DOMImplementation impl = 
SVGDOMImplementation.getDOMImplementation();
        String svgNS = 
SVGDOMImplementation.SVG_NAMESPACE_URI;
        SVGDocument doc = 
(SVGDocument)impl.createDocument(svgNS, "svg", 
null);
        
        
        Container c = getContentPane();
        
        //Now, display the document
        JSVGCanvas canvas = new JSVGCanvas();
        
canvas.setURI("http://localhost:8081/SVGImages/In
tro.svg");

        c.add(canvas);
    }

}


When I run the corresponding HTML page (with the applet 
embedded using the <APPLET> tags) I get this error:

java.lang.NoClassDefFoundError: 
org/apache/batik/swing/JSVGCanvas	
    at java.lang.Class.newInstance0(Native Method)	
    at java.lang.Class.newInstance(Unknown Source)	
    at sun.applet.AppletPanel.createApplet(Unknown 
    Source)	
    at sun.plugin.AppletViewer.createApplet(Unknown 
    Source)	
    at sun.applet.AppletPanel.runLoader(Unknown Source)	
    at sun.applet.AppletPanel.run(Unknown Source)	
    at java.lang.Thread.run(Unknown Source)


I had no problems getting the SVG graphic to view in the 
application (server was running but the application was run from the 
command line). However, when I run the above code on Tomcat it 
causes the above error. Any ideas? How do you get the SVG file to 
work in an applet running on Tomcat? Any help would be great.



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: importing an SVG graphic into an applet

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "CW" == Claire WALL <K9...@atlas.kingston.ac.uk> writes:

CW> Hi, I have successfully managed to import an SVG graphic/file into
CW> an application but when trying to import an SVG graphic into an
CW> applet I am having some problems.

CW> Here�s the code for my applet:

    [...]

CW> When I run the corresponding HTML page (with the applet embedded
CW> using the <APPLET> tags) I get this error:

CW> java.lang.NoClassDefFoundError: org/apache/batik/swing/JSVGCanvas

    Looks like you didn't setup your applet tag to reference the Batik
Jar files.

CW> I had no problems getting the SVG graphic to view in the
CW> application (server was running but the application was run from
CW> the command line). However, when I run the above code on Tomcat it
CW> causes the above error. Any ideas? How do you get the SVG file to
CW> work in an applet running on Tomcat? Any help would be great.

    Hmm, sounds like some confusion here, Applet's run in the clients
Browser, Tomcat is a Servlet container that runs on the server.
Perhaps Tomcat is generating the SVG that is being rendered in an
applet on the client.  So perhaps you setup the classpath for Tomcat
properly but forgot the classpath/archive/whatever attributes on the
applet tag.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org