2012-04-06 34 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