当前位置: 首页 > 工具软件 > Batik > 使用案例 >

java batik_java – Batik传递库依赖项

慕嘉茂
2023-12-01

我正在使用Gradle来获取Batik(一个SVG库)并开箱即用,它缺少一些传递库.我应该放哪一个?

我已经尝试过获取xml-api或Xerces lib

摇篮:

version = 1.0

mainClassName = 'com.foilen.svgexporter.SvgExporter'

sourceCompatibility = '1.8'

targetCompatibility = '1.8'

dependencies {

compile 'args4j:args4j:2.32'

compile 'org.apache.xmlgraphics:batik-rasterizer:1.8'

}

Java代码:

PNGTranscoder transcoder = new PNGTranscoder();

InputStream in = new FileInputStream("character_man_black.svg");

TranscoderInput input = new TranscoderInput(in);

OutputStream ostream = new FileOutputStream("character_man_black.png");

TranscoderOutput output = new TranscoderOutput(ostream);

transcoder.transcode(input, output);

// Flush and close the output.

ostream.flush();

ostream.close();

in.close();

执行错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:760)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)

at java.net.URLClassLoader.access$100(URLClassLoader.java:73)

at java.net.URLClassLoader$1.run(URLClassLoader.java:367)

at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:360)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

at org.apache.batik.anim.dom.SVGDOMImplementation.createDocument(Unknown Source)

at org.apache.batik.dom.util.SAXDocumentFactory.startElement(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:379)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:605)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3138)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:880)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)

at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)

at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)

at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)

at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)

at org.apache.batik.anim.dom.SAXSVGDocumentFactory.createDocument(Unknown Source)

at org.apache.batik.anim.dom.SAXSVGDocumentFactory.createDocument(Unknown Source)

at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)

at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)

at com.foilen.svgexporter.SvgExporter.main(SvgExporter.java:66)

Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal

at java.net.URLClassLoader$1.run(URLClassLoader.java:372)

at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:360)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

... 34 more

谢谢

 类似资料: