Cloudsim3.0.3导入Eclipse各种错误解决方案

来源:互联网 发布:linux删除多个文件 编辑:程序博客网 时间:2024/06/05 07:47

各种范型的报错:

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。