How to import java.nio.file package

2019-02-12 03:03发布

问题:

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!!

回答1:

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.



回答2:

The New I/0 is named as the NIO in javaSE 7.0 ("Dolphin").

The below link described as in details.

wiki - NIO