2012-06-29 31 views
1

我正在嘗試使用Eclipse將AutoIt與Java集成。我已經正確配置了項目和java構建路徑 - 很可能;)。問題是,當我試圖運行的項目,我已經收到以下錯誤提出:在線程「主要」 com.jacob.com.ComFailExceptionJava與AutoIt和Jacob庫

例外:不能在COM共同創建對象 .jacob.com.Dispatch.createInstanceNative(本機方法) 在com.jacob.com.Dispatch。(Dispatch.java:99) 在com.jacob.activeX.ActiveXComponent。(ActiveXComponent.java:58) 在autoitx4java。 AutoItX。(AutoItX.java:181) 在com.mainPackage.windowsGUIHandler.bleble(windowsGUIHandler.java:23) 在com.mainPackage.windowsGUIHandler.main(windowsGUIHandler.java:39)

我的代碼的代碼看起來像這樣(很簡單,但足以運行和測試,如果AutoIt的作品)

package com.mainPackage; 

import java.io.File; 
import com.jacob.com.LibraryLoader; 
import junit.framework.Assert; 
import autoitx4java.AutoItX; 

public class windowsGUIHandler { 

public static void thisIsTestFunction() { 
    File file = new File("lib", "jacob-1.17-M2-x64.dll"); 
    System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath()); 
    LibraryLoader.loadJacobLibrary(); 


    AutoItX x = new AutoItX(); 
    String notepad = "Untitled - Notepad"; 
    String testString = "this is a test."; 
    x.run("notepad.exe"); 
    x.winActivate(notepad); 
    x.winWaitActive(notepad); 
    x.send(testString); 
    Assert.assertTrue(x.winExists(notepad, testString)); 
    x.winClose(notepad, testString); 
    x.winWaitActive("Notepad"); 
    x.send("{ALT}n"); 
    Assert.assertFalse(x.winExists(notepad, testString)); 

} 

public static void main(String[] args) { 
    thisIsTestFunction(); 
} 

} 

我做了一個研究,我發現this article描述做什麼,如果日食返回燦」噸共同創建對象但是當我使用cmd

regasm /冗長/ NOLOGO /基本代碼C:\雅各布-1.17-M2-x64.dll

這個命令我得到一個錯誤RegAsm後:錯誤RA0000:無法加載「C:\雅各-1.17-M2-x64.dll」,因爲它不是一個有效的.NET程序集

另外我m在安裝了JRE和JDK 6 x64的Windows 7 x64上運行。

回答

0

您是在32位處理器機器中使用 Windows 7 32位的機器 或64位機器上的Windows 7 64位。

我試着用 REGSVR32註冊在我的Windows 7 32位雅各-1.17-M2-x86.dll在32位處理器的機器,並與 Windows 7的64成功合作

但在我的另一臺機器bit在64位處理器 既沒有jacob-1.17-M2-x86.dll或jacob-1.17-M2-x64.dll註冊成功。

我不得不使用AutoItX3.dll,它可以通過最新的AutoIT安裝下載。

檢查您的配置並嘗試正確的文件並查看。