Using java.nio from plugin

I’d like to use the ‘java.nio’ package (specifically the ‘java.nio.Files’ class) from my plugin. So I put an import statement at the top of my groovy file:

import java.nio.Files

and I get the following error when building the plugin:

...\Helper.groovy: 6: unable to resolve class java.nio.Files
 @ line 6, column 1.
   import java.nio.Files

Any suggestions?

Just shooting from the hip here so not sure if this is relevant for you but I believe the Files class was introduced in java 1.7. Any chance you are compiling your sources using some earlier version? What does a:

> gradle -version

give you?

Or even better, try changing the:

import java.nio.Files

to a:

import java.nio.file.Files

: )

‘gradle -version’ gives:

Gradle 1.3
  Gradle build time: Tuesday, 20 November 2012 11:37:38 o'clock UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_07 (Oracle Corporation 23.3-b01)
OS: Windows 7 6.1 amd64

Yeah, that was it. Thank you…

(shuffling off in shame)

No worries, happens to the best of us. And I have to say, the file.Files naming convention does not exactly promote obviousness.