實例:創建SWT項目的原生庫導入問題

發表于:2007-04-27來源:作者:點擊數: 標簽:問題原生導入目的SWT
對于 Eclipse 3.1.x 而言,并沒有書中提到的那個“org.eclipse.swt.win32_3.0.1”目錄,自然也不會有目錄下的 swt.jar 和 swt-win32-3063.dll,這個目錄在 Eclipse 3.1.x 中被 org.eclipse.swt.win32.win32.x86_3.1.x.jar 文件替代,而原生庫文件也被壓縮到

  對于 Eclipse 3.1.x 而言,并沒有書中提到的那個“org.eclipse.swt.win32_3.0.1”目錄,自然也不會有目錄下的 swt.jar 和 swt-win32-3063.dll,這個目錄在 Eclipse 3.1.x 中被 org.eclipse.swt.win32.win32.x86_3.1.x.jar 文件替代,而原生庫文件也被壓縮到這個 jar 文件中,用 WinRAR 解壓即可得到。

  在安裝了 SWT Designer 后通過其建立項目時,會自動導入所有必須的 jar 文件到項目中,無需手動導入,但如果之前解壓了 org.eclipse.swt.win32.win32.x86_3.1.x.jar 文件,請將解壓目錄刪除之后再建立項目,否則會導入出錯。這個錯誤是因為導入了解壓得到的 “org.eclipse.swt.win32.win32.x86_3.1.x”目錄,可以手動修改為導入整個 jar 文件就 ok 了。

  接下來是原生庫的導入,我發現用書上的方法導入原生庫到項目中(實際就是將 swt-win32-xxxx.dll 文件復制到項目根目錄),會出現問題。后來翻查《SWT/JFace in Action》得知,有多種方法導入原生庫,但作者發現最好的方法是將 swt-win32-xxxx.dll 文件直接復制到“$Java\jre\bin”目錄下,這樣才不會引起諸多問題。

  總結解決步驟:

 ?、侔惭b Eclipse 3.1.x 和 SWT Designer,解壓 org.eclipse.swt.win32.win32.x86_3.1.x.jar 文件。

 ?、趶椭?swt-win32-xxxx.dll 到“$Java\jre\bin”目錄下。

 ?、蹌h除解壓 org.eclipse.swt.win32.win32.x86_3.1.x.jar 得到的文件夾。

 ?、苄陆?SWT/JFace Java Project,然后就可以直接新建 SWT 類文件了,無需再導入原生包。

  PS:推薦參考《SWT/JFace in Action》配合《Eclipse 入門和精通》進行學習。在《SWT/JFace in Action》附錄“Creating projects with SWT/JFace”中的 316 頁可以找到關于導入原生圖形庫的講述:

clearcase/" target="_blank" >cc3352>  Once you’ve found the graphics library, you need to make sure the application launcher can use it. The documentation lists a number of ways to do this, but we’ve found that adding a copy to the $JAVA/jre/bin directory works best.

  Other methods, which can be less reliable, include the following:

  Option 1: Copy and paste these files directly in the WidgetWindow project.

  Option 2: Include the native library in any directory pointed to by the java.library.path variable. This variable, among others, can be seen by clicking Help->About Eclipse Platform->Configuration Details.

  Option 3: Go to Control Panel->System->Advanced->Environmental Variables and update the PATH variable with the directory containing the library file.


  閱讀關于 SWT 原生庫 導入 問題 的全部文章

原文轉自:http://www.anti-gravitydesign.com

評論列表(網友評論僅供網友表達個人看法,并不表明本站同意其觀點或證實其描述)
...
国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97