![libdbus-java - CreateInterface 失败,出现 [严重错误] introspect.dtd:1:3:](https://linux22.com/image/997896/libdbus-java%20-%20CreateInterface%20%E5%A4%B1%E8%B4%A5%EF%BC%8C%E5%87%BA%E7%8E%B0%20%5B%E4%B8%A5%E9%87%8D%E9%94%99%E8%AF%AF%5D%20introspect.dtd%3A1%3A3%3A.png)
我正在寻找编写一些实用程序脚本时髦的 使用 dbus。根据创建接口以下命令应该为适当的对象生成一个 java 源文件。
CreateInterface --session org.freedesktop.Notifications /org/freedesktop/Notifications
但无论我选择哪个界面尝试生成源文件,命令都会失败
> [Fatal Error] introspect.dtd:1:3: The markup declarations contained or pointed to by the document type declaration must be well-formed.
Exception in thread "main" org.xml.sax.SAXParseExceptionpublicId: -//freedesktop//DTD D-BUS Object Introspection 1.0//EN; systemId: http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd; lineNumber: 1; columnNumber: 3; The markup declarations contained or pointed to by the document type declaration must be well-formed.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at org.freedesktop.dbus.bin.CreateInterface.createInterface(CreateInterface.java:702)
at org.freedesktop.dbus.bin.CreateInterface.main(CreateInterface.java:685)
这发生在 16.04 和 16.10 上。我还没有尝试过其他版本的 Ubuntu。有人知道这个实用程序是否坏了,或者我做错了什么吗?
答案1
只需运行以下命令:
gdbus introspect --session --dest org.freedesktop.Notifications --object-path /org/freedesktop/Notifications --xml | sed -e '/DOCTYPE/d' -e '/introspect.dtd/d' > org.freedesktop.Notifications.xml
CreateInterface --system --create-files org.freedesktop.Notifications.xml