簡體   English   中英

在 Eclipse 上啟動 Java 應用程序時出錯

[英]Error in launching Java application on Eclipse

我剛剛在 Windows 10 上安裝了 Eclipse(2020 版)和 IBM ILOG CPLEX(12.6.9 版),運行 ZD52387880E1EA22817A72D3759218 已經有這個代碼。

The code uses Java API of CPLEX, so I followed these few instructions (on CPLEX Official Page) - they explains to set a jar and a dll filepaths - to set up Eclipse for using Java API of CPLEX.

我遵循了這些步驟,但是當我啟動執行時,我收到了這個錯誤:

Error: Unable to initialize main class Scheduler_1 Caused by: java.lang.NoClassDefFoundError: ilog/concert/IloNumExpr

其他信息:導航到Run > Run Configurations... > Java Application並選擇Arguments tab Show Command Line

`C:\Users\MY_USERNAME\Downloads\eclipse-java-2020-12-R-win32-x86_64\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_15.0.1.v20201027-0507\jre\bin\javaw.exe`

`-Djava.library.path=CPLEX_Studio_Community129/cplex/bin/x64_win64`

`-Dfile.encoding=Cp1252`

`-p "C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\lib\cplex.jar"`

`-classpath "C:\Users\MY_USERNAME\eclipse-workspace\proj1\bin"`

`-XX:+ShowCodeDetailsInExceptionMessages Scheduler_1`

有沒有人知道這可能是我遇到的錯誤的原因?


添加更多詳細信息:這些是我遵循的步驟:

  1. 下載 Eclipse 2020-12 ".zip" 文件並保存在 "Download" 文件夾中,並下載 CPLEX 12.6.9 "exe" 文件

  2. Extract Eclipse 2020-12 "zip" into a folder (with the same name of the "zip") inside "Download", then I install both Eclipse and CPLEX (on Windows 10), by double-clicking on their respective "exe"文件

  3. 打開Eclipse,新建一個Eclipse Java項目,名為proj1

  4. proj1/src/中添加了四個“.java”源文件(從我 PC 的另一個文件夾復制粘貼)

  5. 在 Eclipse GUI 上:

    • Project > Properties > Java Build Path > Libraries
    • 出現對話框時,單擊按鈕Add External JARs
    • 然后瀏覽位置后,我 select 文件名為cplex.jar
  6. 在 Eclipse GUI 上:

    • Run > Run Configurations... > Java Application
    • 當對話框出現時,我 go 到Main tab , select 我的Main Class (稱為Scheduler_1
    • Then, I go to the Arguments tab , I select VM arguments , and add the path to the CPLEX library, so in my case: -Djava.library.path=CPLEX_Studio_Community129/cplex/bin/x64_win64 , which is the path to cplex1290.dll
  7. 我運行 Java 應用程序,我收到錯誤:

Error: Unable to initialize main class Scheduler_1 Caused by: java.lang.NoClassDefFoundError: ilog/concert/IloNumExpr

此外,我的代碼中甚至沒有使用IloNumExpr ,而且,無論如何,它包含在cplex.jar中(我自己檢查過)。

其他細節:這是我項目的directory structure (我可以從Package Explorer中看到,它是 Eclipse Workspace的一部分):

  • proj1
    • src
      • (default packages) :它包含四個“.java”文件(我從我電腦的另一個文件夾中復制粘貼)
    • JRE System Library
    • Referenced Library :它包含cplex.jar (我添加的外部庫)

最后,我似乎解決了我的問題。 我在這里發布對遇到相同錯誤的任何人有用的方法。

我導航到Project -> Properties -> Build Path ,然后單擊Dependencies Tab並從Modulepath Entries中刪除cplex.jar並將其添加到Classpath Entries

現在,之前的錯誤解決了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM