2012-05-07 4 views
1

C:\ JiBXの\チュートリアル\ example23 \ 例23は、今、私はCustomerManagerのJavaをコンパイルしようとしています以下のファイルに難しさのjavacでコンパイルする - 私は、次のディレクトリ構造を持っている問題

enter image description here

が含まれています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 

簡単です今、このファイルには、私のファイルへの参照が含まれています\ JiBXの\ libに(ファイル自体はc:\ JiBXの\チュートリアル\ example23)CなどのTSトップディレクトリ

私はこれらのライブラリを参照するようにして、ファイル

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> 

をコンパイルするには、以下を試してみましたどのように私はcldはこの問題を解決する上で任意の提案?

+0

昨日のおかげでも、あなたが同じ問題を抱えていたし、このフォーラムは、あなたのクラスパスを修正するためにあなたをお勧め

C:\jibx\tutorial>javac -cp .\example23\*;.;.;c:\jibx\lib\jibx-run.jar; .\example23\CustomerManager.java 

。進んでいく前にPATH/CLASSPATHを見てみてください。 – Satya

+0

はい、なぜ私は別の投稿を始めたのか、それらを見ました。私はこれらの投稿に返信するつもりだったが、AddCommentセクションは本当に役に立たなかった。 – Rajeshwar

答えて

3

classpathに.jarファイルを追加する必要があります。

例えば、

javac -cp .;c:\jibx\lib\your_lib.jar example23\CustomerManager.java 
+0

は-cpで-classpathの略語なのだろうか?代わりに-cpを使用できますか? – Rajeshwar

+0

はい!私が投稿したリンクを見てください。 – adatapost

+0

これは私が得たものです - コマンド:C:\ jibx \ tutorial \ example23> javac -cp; c:\ jibx \ lib \ org.eclipse.core.runtime.jar CustomerManager.java出力の一部: CustomerManager.java:7:error:パッケージorg.jibx.runtimeが存在しませんimport org.jibx.runtime。*; ^ javacに*でのインポートを解決できない可能性がありますか? – Rajeshwar

5

あなたの問題は、次の行にある、私は

-classpath c:\jibx\lib\ 

だと思うんが、このディレクトリは、jarファイルが含まれていますか?あなたがそうのようなグロブを使用してみてください可能性があり、その場合の

-classpath c:\jibx\lib\*.jar 

あなたがCにあるすべてのjarファイルが含まれます。この方法:あなたのクラスパスに\ JiBXの\ libに\ディレクトリ。

+0

はい、libファイルは最初のものと私は*を使ってみました。jar styleでも動作しません。 – Rajeshwar

+0

ここに出力があります。[リンク](http://i1076.photobucket.com/albums/w459/rajeshkhan808/output.png) – Rajeshwar

+0

私は何が不足していますか? – Rajeshwar

0

私は、問題を解決するために管理:あなたの偉大な提案

関連する問題