2012-03-27 86 views
0


創建在NetBeans IDE的項目6.9 在一個項目中,我有一個接口IBusinessLogic 在第二個項目中,我創建了一個類BusinessLogic它實現IBusinessLogic 在第三個項目我創建BusienssLogic的對象並將此對象分配給IBusinessLogic的引用。我沒有得到任何錯誤而寫,但是當 我清理並生成第三項目中,我得到異常,下面:乾淨構建失敗在NetBeans

 
incompatible types 
found : com.abc.businesslogic.BusinessLogic 
required: com.abc.businesslogic.interfaces.IBusinessLogic 
       com.abc.businesslogic.interfaces.IBusinessLogic logic = bl; 
Note: Some input files use or override a deprecated API. 
Note: Recompile with -Xlint:deprecation for details. 
Note: Some input files use unchecked or unsafe operations. 
Note: Recompile with -Xlint:unchecked for details. 
1 error 
D:\ProjectsFeb12\Service\nbproject\build-impl.xml:531: The following error occurred while executing this line: 
D:\ProjectsFeb12\Service\nbproject\build-impl.xml:261: Compile failed; see the compiler error output for details. 
BUILD FAILED (total time: 3 seconds) 

當我知道我可以指定在超類型的基準子類型的對象,那麼這異常必須是IDE。我該如何解決這個問題? 我把我的所有代碼都移到了一個新項目中,但沒有成功。

代碼:

 
package com.abc.workerhandlers; 

import com.abc.businesslogic.BusinessLogic; 
import com.abc.businesslogic.interfaces.IBusinessLogic; 

public class MQ2MQWorker1 { 

    MQ2MQWorker1(){} 

    public void init(){ 

       BusinessLogic bl = new BusinessLogic(); 
       IBusinessLogic logic = bl; // This line is giving problem 
    } 
} 

當我運行它完美地執行該項目,但該項目的罐子在dist目錄中沒有創建。

+0

你可以發佈一段代碼的錯誤所在出現? – 2012-03-27 06:21:51

+0

您確定'com.abc.businesslogic.BusinessLogic'實現了'com.abc.businesslogic.interfaces.IBusinessLogic'嗎? – 2012-03-27 06:21:53

+0

@JimGarrison我確定。 – sjain 2012-03-27 06:30:15

回答

0

你確定類路徑中有正確的類嗎?順便說一句,你 不應該寫

BusinessLogic bl = new BusinessLogic(); 
IBusinessLogic logic = bl; // This line is giving problem 

而只是IBUsinessLogic logic = new BusinessLogic();