麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 系統(tǒng) > Windows > 正文

Windows環(huán)境下Java加載DLL

2020-05-27 13:11:41
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

   How to Load a Java Native/Dynamic Library (DLL)

  There are several ways to make it possible for the Java runtime to find and load a dynamic library (DLL) at runtime. I will list them briefly here, followed by examples and further explanation below.

  Call System.load to load the DLL from an explicitly specified absolute path.

  Copy the DLL to one of the paths already listed in java.library.path

  Modify the PATH environment variable to include the directory where the DLL is located.

  Specify the java.library.path on the command line by using the -D option.

  If using Eclipse, set the java.library.path in Eclipse for development/debugging.

  1. Call System.load to load the DLL from an explicitly specified absolute path.

  This choice removes all uncertainty, but embeds a hard-coded path within your Java application. Example:

  import com.chilkatsoft.CkZip;public class Test { static { try { System.load("C:/chilkatJava/chilkat.dll"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load./n" + e); System.exit(1); } } public static void main(String argv[]) { CkZip zip = new CkZip(); System.out.println(zip.version()); }}

  2. Copy the DLL to one of the paths already listed in java.library.path

  To see the current value of the PATH environment variable, open a MS-DOS prompt and type:

  echo %PATH%

  Another way of viewing the java.library.path is to run this Java code:

  String property = System.getProperty("java.library.path");StringTokenizer parser = new StringTokenizer(property, ";");while (parser.hasMoreTokens()) { System.err.println(parser.nextToken()); }

  Note: The java.library.path is initialized from the PATH environment variable. The directories may be listed in a different order, and the current directory "." should be present in java.library.path, but may not be listed in the PATH environment variable.

  The loadLibrary method may be used when the directory containing the DLL is in java.library.path. To load "chilkat.dll", call System.loadLibrary("chilkat"), as shown here:

  import com.chilkatsoft.CkZip;public class Test { static { try { System.loadLibrary("chilkat"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load./n" + e); System.exit(1); } } public static void main(String argv[]) { CkZip zip = new CkZip(); System.out.println(zip.version()); } }

  3. Modify the PATH environment variable to include the directory where the DLL is located.

  Do this by modifying the PATH environment variable from the Windows Control Panel.

  Set PATH on Windows XP:

  Start -> Control Panel -> System -> Advanced

  Click on Environment Variables, under System Variables, find PATH, and click on it.

  In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.

  Close the window.

  Reopen Command prompt window, and run your java code.

  Set Path on Windows Vista:

  Right click “My Computer” icon

  Choose “Properties” from context menu

  Click “Advanced” tab (“Advanced system settings” link in Vista)

  In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.

  Reopen Command prompt window, and run your java code.

  Important: Setting the PATH environment variable from a MS-DOS command prompt has no effect on java.library.path. For example, this does not work:

  set PATH=c:/chilkatJava;%PATH%java Test

  Also, modifying the java.library.path from within Java code does not work either:

  static { try { // Adding a directory to java.library.path here will not change anything. // System.loadLibrary will still look in the directories listed in java.library.path // as it existed at the very start of the program. // The extra directory path added to java.library.path will not // be searched by loadLibrary. String libpath = System.getProperty("java.library.path"); libpath = libpath + ";C:/chilkatJava"; System.setProperty("java.library.path",libpath); System.loadLibrary("chilkat"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load./n" + e); System.exit(1); } }

  4. Specify the java.library.path on the command line by using the -D option.

  For example:

  java -Djava.library.path=c:/chilkatJava TestApp

  5. If using Eclipse, set the java.library.path in Eclipse for development/debugging.

  Open Project->Properties, select “Java Build Path”, click on the “Add External JARs…” button and add the “chilkat.jar”

  (still within the Project Properties dialog) Click on the “Run/Debug Settings”, select your Java class, then click on the “Edit…” button. Select the “Arguments” tab, then add -Djava.library.path=”C:/chilkatJava;${env_var:PATH}” where “C:/chilkatJava” is the directory path containing the “chilkat.dll” file.

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 亚洲性爰 | 国产欧美日韩在线不卡第一页 | 高颜值美女啪啪 | 精品亚洲二区 | 久久成人视屏 | 欧美一级免费在线观看 | 麻豆一区二区99久久久久 | 国产小视频在线观看 | 欧美视屏一区二区 | 国产午夜电影在线观看 | av手机在线免费播放 | 最新亚洲国产 | 国产精品美女久久久久久不卡 | 精品国产一区二区三区在线观看 | 伦理三区 | 成人在线视频播放 | 一级成人免费 | caoporn国产一区二区 | 国产一区免费视频 | 成人免费一区二区三区在线观看 | 国产精品入口夜色视频大尺度 | 国产五区| 欧美电影在线观看 | 免费国产成人高清在线看软件 | 日韩在线播放中文字幕 | 在火车上摸两乳爽的大叫 | 久久亚洲国产精品 | 久久免费综合视频 | 免费的性生活视频 | 免费a视频在线观看 | 日本一区二区免费在线观看 | 毛片免费看电影 | www.99av| 国产精品1区,2区,3区 | 男女一边摸一边做羞羞视频免费 | 精品国产亚洲人成在线 | 香蕉成人在线观看 | 色妞视频男女视频 | 久久久久av电影 | 中文字幕www | 毛片在线免费观看视频 |