我在 Java 中使用 KML 对象。我想将此对象导出到文件。我尝试用 JAK 库编写这个函数,函数 KML.marshal() 但它没有成功。我收到此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/xml/bind/marshaller/NamespacePrefixMapper
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at de.micromata.opengis.kml.v_2_2_0.Kml.createMarshaller(Kml.java:642)
at de.micromata.opengis.kml.v_2_2_0.Kml.marshal(Kml.java:682)
at de.micromata.opengis.kml.v_2_2_0.Kml.marshal(Kml.java:759)
at com.nice.nicetrack.KMLGenerator.toKML(KMLGenerator.java:141)
at com.nice.nicetrack.KMLGenerator.main(KMLGenerator.java:240)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.marshaller.NamespacePrefixMapper
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 17 more
我不想使用 XML 或字符串格式。只有 KMl 对象!!请帮我!!谢谢!