Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自java库的错误";citygml4j“;_Java - Fatal编程技术网

来自java库的错误";citygml4j“;

来自java库的错误";citygml4j“;,java,Java,我是一名新程序员,我想编写java程序并使用CityGML4j库。我看到了citygml4j程序的一些示例,但当我在netbeans中运行它们时,我看到了以下错误: 线程“main”java.lang.NoClassDefFoundError中出现异常:com/sun/xml/stream/writers/XMLWriter 位于org.citygml4j.builder.jaxb.xml.io.writer.JAXBOutputFactory.createCityGMLWriter(未知源)

我是一名新程序员,我想编写java程序并使用CityGML4j库。我看到了citygml4j程序的一些示例,但当我在netbeans中运行它们时,我看到了以下错误:

线程“main”java.lang.NoClassDefFoundError中出现异常:com/sun/xml/stream/writers/XMLWriter 位于org.citygml4j.builder.jaxb.xml.io.writer.JAXBOutputFactory.createCityGMLWriter(未知源) 位于org.citygml4j.builder.jaxb.xml.io.writer.JAXBOutputFactory.createCityGMLWriter(未知源) 位于buildingcreator.buildingcreator.doMain(buildingcreator.java:113) 位于buildingcreator.buildingcreator.main(buildingcreator.java:46) 原因:java.lang.ClassNotFoundException:com.sun.xml.stream.writers.XMLWriter 在java.net.URLClassLoader$1.run(URLClassLoader.java:372) 在java.net.URLClassLoader$1.run(URLClassLoader.java:361) 位于java.security.AccessController.doPrivileged(本机方法) 位于java.net.URLClassLoader.findClass(URLClassLoader.java:360) 位于java.lang.ClassLoader.loadClass(ClassLoader.java:424) 位于sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 位于java.lang.ClassLoader.loadClass(ClassLoader.java:357)

Java程序:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package buildingcreator;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.citygml4j.CityGMLContext;
import org.citygml4j.builder.CityGMLBuilder;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.CityGMLClass;
import org.citygml4j.model.citygml.building.AbstractBoundarySurface;
import org.citygml4j.model.citygml.building.BoundarySurfaceProperty;
import org.citygml4j.model.citygml.building.Building;
import org.citygml4j.model.citygml.building.GroundSurface;
import org.citygml4j.model.citygml.building.RoofSurface;
import org.citygml4j.model.citygml.building.WallSurface;
import org.citygml4j.model.citygml.core.CityModel;
import org.citygml4j.model.citygml.core.CityObjectMember;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurface;
import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.citygml4j.model.gml.geometry.complexes.CompositeSurface;
import org.citygml4j.model.gml.geometry.primitives.Polygon;
import org.citygml4j.model.gml.geometry.primitives.Solid;
import org.citygml4j.model.gml.geometry.primitives.SolidProperty;
import org.citygml4j.model.gml.geometry.primitives.SurfaceProperty;
import org.citygml4j.model.module.citygml.CityGMLVersion;
import org.citygml4j.util.gmlid.DefaultGMLIdManager;
import org.citygml4j.util.gmlid.GMLIdManager;
import org.citygml4j.xml.io.CityGMLOutputFactory;
import org.citygml4j.xml.io.writer.CityGMLWriter;

/**
 *
 * @author Simin
 */
public class BuildingCreator {
    public static void main(String[] args) throws Exception {
        new BuildingCreator().doMain();
    }

    public void doMain() throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

        System.out.println(df.format(new Date()) + "setting up citygml4j context and JAXB builder");
        CityGMLContext ctx = new CityGMLContext();
        CityGMLBuilder builder = ctx.createCityGMLBuilder();

        System.out.println(df.format(new Date()) + "creating LOD2 building as citygml4j in-memory object tree");
        GMLGeometryFactory geom = new GMLGeometryFactory();

        GMLIdManager gmlIdManager = DefaultGMLIdManager.getInstance();

        Building building = new Building();

        Polygon ground = geom.createLinearPolygon(new double[] {0,0,0, 0,12,0, 6,12,0, 6,0,0, 0,0,0}, 3);
        Polygon wall_1 = geom.createLinearPolygon(new double[] {6,0,0, 6,12,0, 6,12,6, 6,0,6, 6,0,0}, 3);
        Polygon wall_2 = geom.createLinearPolygon(new double[] {0,0,0, 0,0,6, 0,12,6, 0,12,0, 0,0,0}, 3);
        Polygon wall_3 = geom.createLinearPolygon(new double[] {0,0,0, 6,0,0, 6,0,6, 3,0,9, 0,0,6, 0,0,0}, 3);
        Polygon wall_4 = geom.createLinearPolygon(new double[] {6,12,0, 0,12,0, 0,12,6, 3,12,9, 6,12,6, 6,12,0}, 3);
        Polygon roof_1 = geom.createLinearPolygon(new double[] {6,0,6, 6,12,6, 3,12,9, 3,0,9, 6,0,6}, 3);
        Polygon roof_2 = geom.createLinearPolygon(new double[] {0,0,6, 3,0,9, 3,12,9, 0,12,6, 0,0,6}, 3);

        ground.setId(gmlIdManager.generateUUID());
        wall_1.setId(gmlIdManager.generateUUID());
        wall_2.setId(gmlIdManager.generateUUID());
        wall_3.setId(gmlIdManager.generateUUID());
        wall_4.setId(gmlIdManager.generateUUID());
        roof_1.setId(gmlIdManager.generateUUID());
        roof_2.setId(gmlIdManager.generateUUID());

        // lod2 solid
        List<SurfaceProperty> surfaceMember = new ArrayList<SurfaceProperty>();
        surfaceMember.add(new SurfaceProperty('#' + ground.getId()));
        surfaceMember.add(new SurfaceProperty('#' + wall_1.getId()));
        surfaceMember.add(new SurfaceProperty('#' + wall_2.getId()));
        surfaceMember.add(new SurfaceProperty('#' + wall_3.getId()));
        surfaceMember.add(new SurfaceProperty('#' + wall_4.getId()));
        surfaceMember.add(new SurfaceProperty('#' + roof_1.getId()));
        surfaceMember.add(new SurfaceProperty('#' + roof_2.getId()));

        CompositeSurface compositeSurface = new CompositeSurface();
        compositeSurface.setSurfaceMember(surfaceMember);       
        Solid solid = new Solid();
        solid.setExterior(new SurfaceProperty(compositeSurface));

        building.setLod2Solid(new SolidProperty(solid));

        // thematic boundary surfaces
        List<BoundarySurfaceProperty> boundedBy = new ArrayList<BoundarySurfaceProperty>();
        boundedBy.add(createBoundarySurface(CityGMLClass.BUILDING_GROUND_SURFACE, ground));
        boundedBy.add(createBoundarySurface(CityGMLClass.BUILDING_WALL_SURFACE, wall_1));
        boundedBy.add(createBoundarySurface(CityGMLClass.BUILDING_WALL_SURFACE, wall_2));
        boundedBy.add(createBoundarySurface(CityGMLClass.BUILDING_WALL_SURFACE, wall_3));
        boundedBy.add(createBoundarySurface(CityGMLClass.BUILDING_WALL_SURFACE, wall_4));
        boundedBy.add(createBoundarySurface(CityGMLClass.BUILDING_ROOF_SURFACE, roof_1));
        boundedBy.add(createBoundarySurface(CityGMLClass.BUILDING_ROOF_SURFACE, roof_2));       
        building.setBoundedBySurface(boundedBy);

        CityModel cityModel = new CityModel();
        cityModel.setBoundedBy(building.calcBoundedBy(false));
        cityModel.addCityObjectMember(new CityObjectMember(building));

        System.out.println(df.format(new Date()) + "writing citygml4j object tree");
        CityGMLOutputFactory out = builder.createCityGMLOutputFactory(CityGMLVersion.DEFAULT);
            CityGMLWriter writer = out.createCityGMLWriter(new File("LOD2_Building_v200.gml"));
        writer.setPrefixes(CityGMLVersion.DEFAULT);
        writer.setSchemaLocations(CityGMLVersion.DEFAULT);
        writer.setIndentString("  ");
        writer.write(cityModel);    
                writer.close(); 

        System.out.println(df.format(new Date()) + "CityGML file LOD2_Building_v200.gml written");
        System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
    }

    private BoundarySurfaceProperty createBoundarySurface(CityGMLClass type, Polygon geometry) {
        AbstractBoundarySurface boundarySurface = null;

        switch (type) {
        case BUILDING_WALL_SURFACE:
            boundarySurface = new WallSurface();
            break;
        case BUILDING_ROOF_SURFACE:
            boundarySurface = new RoofSurface();
            break;
        case BUILDING_GROUND_SURFACE:
            boundarySurface = new GroundSurface();
            break;
        default:
            break;
        }

        if (boundarySurface != null) {
            boundarySurface.setLod2MultiSurface(new MultiSurfaceProperty(new MultiSurface(geometry)));
            return new BoundarySurfaceProperty(boundarySurface);
        }

        return null;

        }
}
/*
*要更改此许可证标题,请在“项目属性”中选择“许可证标题”。
*要更改此模板文件,请选择工具|模板
*然后在编辑器中打开模板。
*/
包构建创建者;
导入java.io.File;
导入java.text.simpleDataFormat;
导入java.util.ArrayList;
导入java.util.Date;
导入java.util.List;
导入org.citygml4j.CityGMLContext;
导入org.citygml4j.builder.CityGMLBuilder;
导入org.citygml4j.factory.GMLGeometryFactory;
导入org.citygml4j.model.citygml.CityGMLClass;
导入org.citygml4j.model.citygml.building.AbstractBoundarySurface;
导入org.citygml4j.model.citygml.building.BoundarySurfaceProperty;
导入org.citygml4j.model.citygml.building.building;
导入org.citygml4j.model.citygml.building.GroundSurface;
导入org.citygml4j.model.citygml.building.rootsurface;
导入org.citygml4j.model.citygml.building.wallssurface;
导入org.citygml4j.model.citygml.core.CityModel;
导入org.citygml4j.model.citygml.core.CityObjectMember;
导入org.citygml4j.model.gml.geometry.aggregates.MultiSurface;
导入org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
导入org.citygml4j.model.gml.geometry.complements.CompositeSurface;
导入org.citygml4j.model.gml.geometry.primitives.Polygon;
导入org.citygml4j.model.gml.geometry.primitives.Solid;
导入org.citygml4j.model.gml.geometry.primitives.SolidProperty;
导入org.citygml4j.model.gml.geometry.primitives.SurfaceProperty;
导入org.citygml4j.model.module.citygml.CityGMLVersion;
导入org.citygml4j.util.gmlid.DefaultGMLIdManager;
导入org.citygml4j.util.gmlid.GMLIdManager;
导入org.citygml4j.xml.io.CityGMLOutputFactory;
导入org.citygml4j.xml.io.writer.CityGMLWriter;
/**
*
*@作者斯敏
*/
公共类构建创建者{
公共静态void main(字符串[]args)引发异常{
新建BuildingCreator().doMain();
}
public void doMain()引发异常{
SimpleDataFormat df=新的SimpleDataFormat(“[HH:mm:ss]”);
System.out.println(df.format(new Date())+“设置citygml4j上下文和JAXB生成器”);
CityGMLContext ctx=新的CityGMLContext();
CityGMLBuilder=ctx.createCityGMLBuilder();
System.out.println(df.format(new Date())+“在内存对象树中将LOD2建筑创建为citygml4j”);
GMLGeometryFactory geom=新的GMLGeometryFactory();
GMLIdManager GMLIdManager=DefaultGMLIdManager.getInstance();
建筑物=新建筑物();
多边形地面=geom.createLinearPolygon(新的双[]{0,0,0,0,12,0,6,12,0,6,0,0,0,0},3);
多边形wall_1=geom.createLinearPolygon(新的双[]{6,0,0,6,12,0,6,12,6,6,0,6,0},3);
多边形wall_2=geom.createLinearPolygon(新的双[]{0,0,0,0,6,0,12,6,0,12,0,0,0},3);
多边形wall_3=geom.createLinearPolygon(新的双[]{0,0,0,6,0,0,6,3,0,9,0,0,6,0,0},3);
多边形wall_4=geom.createLinearPolygon(新的双[]{6,12,0,12,0,0,12,6,3,12,9,6,12,6,6,6,12,0},3);
多边形屋顶_1=geom.createLinearPolygon(新的双[]{6,0,6,6,12,6,3,12,9,3,0,9,6,0,6},3);
多边形屋顶_2=geom.createLinearPolygon(新的双[]{0,0,6,3,0,9,3,12,9,0,12,6,0,0,6},3);
ground.setId(gmlIdManager.generateuid());
wall_1.setId(gmlIdManager.generateuid());
wall_2.setId(gmlIdManager.generateuid());
wall_3.setId(gmlIdManager.generateuid());
wall_4.setId(gmlIdManager.generateuid());
roof_1.setId(gmlIdManager.generateuid());
roof_2.setId(gmlIdManager.generateuid());
//lod2固体
List surfaceMember=new ArrayList();
添加(新的SurfaceProperty(“#”+ground.getId());
添加(新的SurfaceProperty('#'+wall_1.getId());
添加(新的SurfaceProperty('#'+wall_2.getId());
添加(新的SurfaceProperty('#'+wall_3.getId());
添加(新的SurfaceProperty('#'+wall_4.getId());
添加(新的SurfaceProperty(“#”+roof_1.getId());
添加(新的SurfaceProperty(“#”+roof_2.getId());
CompositeSurface CompositeSurface=新CompositeSurface();
复合曲面。设置曲面成员(曲面成员);
实体=新实体();
solid.setExterior(新表面属性(复合表面));
building.setLod2Solid(新SolidProperty(solid));
//专题边界面
List boundedBy=new ArrayList();
添加(createBoundarySurface(CityGMLClass.BUILDING_GROUND_SURFACE,GROUND));
添加(createBoundarySurface(CityGMLClass.BUILDING_WALL_SURFACE,WALL_1));
boundby.add(cr)
<dependency>
  <groupId>org.citygml4j</groupId>
  <artifactId>citygml4j</artifactId>
  <version>2.2</version>
</dependency>