File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Game Development and the fly likes System.nanoTime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "System.nanoTime" Watch "System.nanoTime" New topic


Angelo D'Ercole

Joined: Mar 29, 2006
Posts: 1
I had the following error when I try to compile a java program that have a System.nanoTime method: cannot resolve symbol
symbol : method nanoTime ()
location: class java.lang.System
count1 = System.nanoTime();

I checked for the JRE and JDK installation and it seems to be correct:

J2SE Development Kit 5.0 Update 6
J2SE Runtime Environment 5.0 Update 6
Java 2 Runtime Environment, SE v1.4.2_10
Java 2 SDK, SE v1.4.2_10

I installed the Java 3D 1.3.2 by unzipping it into the jre directory version 1.5.

I cannot understand where is the problem....maybe the classpath?

I also verified that:

java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

really I noted that I don't have javac.exe program into my installation directory C:\java15.
Than I used the javac.exe of the 1.4 version from the C:\java14 directory.

Thanks for the help.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Hi Angelo,

Welcome to JavaRanch!

The nanoTime() method is new in Java 5 (also called JDK 1.5). Anything older won't recognize it, including JDK 1.4.

It's OK to have multiple versions of Java on one machine, but you do need to keep them straight, and make sure you know that the API you're using corresponds to the Java version of both the compiler and the runtime you're using. Finally, note that if you use this API (and even if you don't, but you compile with a JDK 1.5 compiler), your class files won't run on a JDK 1.4 runtime.

You need to find the JDK 1.5 installation directory, and use the javac.exe from there.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: System.nanoTime
It's not a secret anymore!