我试图将Obix与Java一起使用,因此我在Google中找到了一个非常简单的教程。我有所有库,如:obix.jar,dom.jar,jaxen-full.jar,sax.jar,saxpath.jar和xercesImpl.jar。
sample.config.xml是:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration SYSTEM "http://obix-framework.sourceforge.net/docs/obix-configuration.dtd">
<configuration>
<entry entryKey="message">
<value>Hello World!</value>
</entry>
</configuration>
Java代码是:
import static java.lang.System.out;
import org.obix.configuration.Configuration;
import org.obix.configuration.ConfigurationAdapter;
import org.obix.configuration.ConfigurationAdapterFactory;
public final class ObixSample {
public static void main(final String[] args) {
final ConfigurationAdapterFactory factory = ConfigurationAdapterFactory.newAdapterFactory();
final Configuration config = Configuration.getConfiguration();
final ConfigurationAdapter adapter = factory.create(null);
adapter.adaptConfiguration(config, "sample.config");
out.println(config.getStringValue("message"));
}
}
所以在Eclipse中,导入的前三行是红色的,它表示
导入org.obix无法解析
如何解决此问题?
答案 0 :(得分:0)
您必须在Java Build Path中拥有所有相关的JAR。
Right click Project > Build Path > Configure Build Path > Java build Path > Add JARs in Libraries tab