小编sim*_*ran的帖子

java.net.MalformedURLException:没有协议

我正在编写一个在java中运行xjc的类.我的代码如下:

 URL url = new URL("C:\\Users\\Simran\\Desktop\\books.xsd"); 
 SchemaCompiler sc = XJC.createSchemaCompiler();
 sc.parseSchema(new InputSource(url.toExternalForm()));
 S2JJAXBModel model = sc.bind();
 JCodeModel cm = model.generateCode(null, null);
 cm.build(new FileCodeWriter(new File("C:\\Users\\Simran\\Desktop\\books.xsd")));
Run Code Online (Sandbox Code Playgroud)

但是当我运行这个时,我收到以下错误:

Exception in thread "main" java.net.MalformedURLException: no protocol: books.xsd
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at jaxbTest.Test1.main(Test1.java:22)
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

java url jaxb xjc

8
推荐指数
2
解决办法
6万
查看次数

标签 统计

java ×1

jaxb ×1

url ×1

xjc ×1