Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

System.nanoTime  RSS feed

Angelo D'Ercole
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24217
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!