2012-04-06 26 views
7

Trong khi biên dịch ứng dụng libgdx tôi trong nhật thực tôi cứ bị lỗi này:Phương pháp nanoTime() là undefined cho các loại hệ thống trong 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 

nào ngụ ý rằng GWT không hỗ trợ .nanoTime(), là thế này trường hợp hoặc tôi chỉ đơn giản là chạy với JRE sai? (Tôi đã kiểm tra dự án và nó nói là 1.6).

+0

[ 'System.nanoTime()'] (http://docs.oracle.com/javase/7/docs/api/java/lang/System.html# nanoTime()) đã có trong JDK từ Java 1.5, vì vậy chắc chắn không phải là trường hợp JRE của bạn quá cũ. –

+0

Tôi có cùng lỗi với String.format. : D – Emerald214

Trả lời

10

Không có hỗ trợ cho nanoTime() trong GWT vì không có hỗ trợ cho nó trong javascript.

Các analog gần nhất trong GWT là Duration.currentTimeMillis()

+2

Hãy thêm liên kết vào tài liệu: https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation –

Các vấn đề liên quan