我有以下目錄結構 C:\ JiBX的\教程\ example23 \ 的例子23包含以下文件難度用javac編譯 - 問題
現在我試圖編譯的CustomerManager的java文件只它引用了的CustomerManager的java文件,這folder.The代碼其它類是直接
package example23;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import org.jibx.runtime.*;
public class CustomerManager
{
public CustomerManager()
{
try
{
IBindingFactory bfact = BindingDirectory.getFactory(Customer.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
Object obj = uctx.unmarshalDocument(new FileInputStream("C:/jibx/tutorial/example23/customer.xml"), null);
Customer customer = (Customer)obj;
System.out.print(customer.street+", "+customer.city);
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(4);
mctx.marshalDocument(obj, "UTF-8", null, new FileOutputStream("C:/jibx/tutorial/example23/customer2.xml"));
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (JiBXException e)
{
e.printStackTrace();
}
} //end method
public static void main(String[] args)
{
new CustomerManager();
}
}//end class
現在這個文件包含在我的文件引用TS頂部目錄,如C:\的JiBX \ lib中(該文件本身是在C:\的JiBX \教程\ example23)
我嘗試以下引用這些庫和編譯文件
C:\jibx\tutorial>javac -classpath c:\jibx\lib\ example23\CustomerManager.java
and the output i got was
example23\CustomerManager.java:7: error: package org.jibx.runtime does not exist
import org.jibx.runtime.*;
^
example23\CustomerManager.java:16: error: cannot find symbol
IBindingFactory bfact = BindingDirectory.getFactory(Customer.class);
^
symbol: class IBindingFactory
location: class CustomerManager
example23\CustomerManager.java:16: error: cannot find symbol
IBindingFactory bfact = BindingDirectory.getFactory(Customer.class);
^
symbol: class Customer
location: class CustomerManager
example23\CustomerManager.java:16: error: cannot find symbol
IBindingFactory bfact = BindingDirectory.getFact
ory(Customer.class);
^
symbol: variable BindingDirectory
location: class CustomerManager
example23\CustomerManager.java:17: error: cannot find symbol
IUnmarshallingContext uctx = bfact.createUnmarsh
allingContext();
^
symbol: class IUnmarshallingContext
location: class CustomerManager
example23\CustomerManager.java:20: error: cannot find symbol
Customer customer = (Customer)obj;
^
symbol: class Customer
location: class CustomerManager
example23\CustomerManager.java:20: error: cannot find symbol
Customer customer = (Customer)obj;
^
symbol: class Customer
location: class CustomerManager
example23\CustomerManager.java:22: error: cannot find symbol
IMarshallingContext mctx = bfact.createMarshalli
ngContext();
^
symbol: class IMarshallingContext
location: class CustomerManager
example23\CustomerManager.java:30: error: cannot find symbol
catch (JiBXException e)
^
symbol: class JiBXException
location: class CustomerManager
9 errors
C:\jibx\tutorial>
有關我如何解決這個問題的任何建議?
昨天你也有同樣的問題,這個論壇建議您糾正你的classpath。在繼續進行之前,您能否請嘗試查看PATH/CLASSPATH? – Satya
是的,我確實看過他們這就是爲什麼我開始另一個職位。我打算回覆這些帖子,但AddComment部分並不真的有幫助 – Rajeshwar