Cloudsim3.0.3導入Eclipse各種錯誤解決方案

各種範型的報錯:

1、Syntax error,parameterized types are only available if source level is 1.5

總是報錯,提示Syntax error,parameterized types are only available if source level is 5.0

原因是:我們的項目編譯的時候使用的jdk版本低於5.0

解決方法如下:

在Myeclipse IDE中的菜單Window/Preferences/Java/Compiler裏改爲1.6
或者在單個項目裏設置了source level 爲5.0以上以下(在項目屬性/Java Compiler 裏改爲5.0或高於5.0)


2、Example7中:The method run() of type new Runnable(){} must override a superclass method

這是因爲@Override的方式適用於jdk1.7之前的Runnable接口:

JDK1.8中將Runnable標記爲@FunctionalInterface函數式編程接口:

// Java 8之前:
    new Thread(new Runnable() {
        @Override
        public void run() {
            System.out.println("Before Java8, too much code for too little to do");
        }
    }).start();
//Java 8方式:
    new Thread( () -> System.out.println("In Java8, Lambda expression rocks !!")
解決方法:同上


3、Example7中:import org.apache.commons.math3.linear.Array2DRowRealMatrix;出錯

這是因爲cloudsim3.0.3開始不在使用flanagan.jar而是用math3庫來進行科學計算。原文:

  • Removed the dependency on the flanagan library. It is now replaced with Apache Math. The implementation and interface of the MathUtil has been changed accordingly

解決方案:下載math3庫(http://commons.apache.org/proper/commons-math/download_math.cgi)並add external jar。





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章