aspose file tools*
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
Author

System.nanoTime

Angelo D'Ercole
Greenhorn

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:

TimerRes.java:96: 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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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: http://aspose.com/file-tools
 
subject: System.nanoTime