Search code examples
fileimportniojava

How to import java.nio.file package


Im trying to listen to a directory for changes, then discovered java.nio.* was developed to handle efficiently such tasks and more. Then downloaded jdk1.7.0_02 from oracle and started eclipse with it. Then created new java project, tryed to implement some class from java.nio.file and Oh my eyes! "The import java.nio.file cannot be resolved". Do i have to find some .jar in the whole jdk1.7.0_02 directory that contains such package? or is something wrong with my classpath? Thank you in advance!!


Solution

  • You've different version of JDKs. You just need to set JDK7/JRE7 version eclipse project. You may also select the Execution environment JRE to JavaSE 7 while creating a new project.

    The JDK your projects use to compile, the version of the resulting class files, the JRE they used to execute and the JDK eclipse runs with are widely independent settings.