2017-04-14 132 views
1

我有Individual.XML放在目錄:文件\ InputApps無法打印結果

<?xml version="1.0" encoding="UTF-8"?> 
-<topmostSubform> 
-<Header1> 
<TextField2>**A123**</TextField2> 
</Header1> 

只是想打印出 「A123」 但我得到這錯誤

Exception in thread "main" java.lang.NoClassDefFoundError: org/xmlbeam/XBProjector 
    at rb.form.submitter.Function_Library.printWeatherData(Function_Library.java:758) 
    at rb.form.submitter.RB_base.main(RB_base.java:81) 
Caused by: java.lang.ClassNotFoundException: org.xmlbeam.XBProjector 
    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) 

請參閱下面我的XMLBean代碼:

@XBDocURL("resource://Files//InputApps//Individual.XML") 

public interface XMLData { 
    @XBRead("/topmostSubform/Header1/TextField2")  
    String getValue(); 
} 

protected void printData() throws IOException { 
    // We let the projector fetch the data for us 
    XMLData ValueData = new XBProjector().io().fromURLAnnotation(XMLData.class); 

    // Print some values 
    System.out.println("test " + ValueData.getValue()); 
} 

回答

0

您正在使用外部庫(enter link description here),但該庫在執行期間不在您的類路徑中。您必須將庫內容添加到jar(創建fat jar),或者爲執行提供有效的類路徑(java.exe -cp ...)。

+0

Thanks @cfx是的,我能夠通過在Jar文件中添加庫來使其工作。你能幫我解決我的另一個問題嗎? [鏈接這裏](http://stackoverflow.com/questions/43831634/how-to-map-two-similar-xml-element-using-xmlbeam) – ebanster