2012-04-06 48 views
7

类型系统在编译时在Eclipse我libgdx应用我不断收到此错误:方法nanoTime()是未定义在GWT

[ERROR] Errors in 'file:/C:/Users/Zorfie/Programing/Java/workspace/Libgdx/src/sim/states/BasicBox2DState.java' 
     [ERROR] Line 157: The method nanoTime() is undefined for the type System 
     [ERROR] Line 159: The method nanoTime() is undefined for the type System 
     [ERROR] Line 160: The method nanoTime() is undefined for the type System 
     [ERROR] Line 161: The method nanoTime() is undefined for the type System 
    [ERROR] Errors in 'jar:file:/C:/Program%20Files/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201203300216-rel-r37/gwt-2.4.0/gwt-user.jar!/com/google/web/bindery/autobean/shared/impl/StringQuoter.java' 
     [ERROR] Line 21: The import org.json cannot be resolved 
     [ERROR] Line 69: JSONObject cannot be resolved 
    [ERROR] Errors in 'jar:file:/C:/Program%20Files/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201203300216-rel-r37/gwt-2.4.0/gwt-user.jar!/com/google/web/bindery/autobean/vm/impl/JsonSplittable.java' 
     [ERROR] Line 23: The import org.json cannot be resolved 
     [ERROR] Line 24: The import org.json cannot be resolved 
     [ERROR] Line 25: The import org.json cannot be resolved 
     [ERROR] Line 40: JSONObject cannot be resolved to a type 
     [ERROR] Line 47: JSONObject cannot be resolved to a type 

这意味着GWT不支持.nanoTime(),这是这种情况还是我只是用错误的JRE运行? (我检查了这个项目,它说它是1.6)。

+0

['System.nanoTime()'](http://docs.oracle.com/javase/7/docs/api/java/lang/System.html# nanoTime())自Java 1.5以来一直在JDK中,所以绝对不是您的JRE太旧的情况。 – 2012-04-06 17:01:09

+0

我有与String.format相同的错误。 :D – Emerald214 2017-02-24 04:53:06

回答

10

GWT中不支持nanoTime(),因为在javascript中不支持它。

在GWT最接近的类似物是Duration.currentTimeMillis()

+2

我们还添加一个链接到文档:https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation – 2012-04-06 18:12:09