Java中构造函数File(String)未定义

package nmd;
import java.io.*;
public class FileHello {
public static void main(String[] args) {
try {
Runtime ec=Runtime.getRuntime();
File file=new File("file.txt");
ec.exec(file.getAbsolutePath());

    } catch (Exception e) {
        System.out.println(e);
    }
}

}
照着课本例题打的,以前忘了用的哪个版本的eclipse,是可以运行的,可现在换了版本是KEPLER的eclipse却无法运行,总是报错Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The constructor File(String) is undefined
The method getAbsolutePath() is undefined for the type File

at nmd.FileHello.main(FileHello.java:8)

求大神指点!

import java.io.File

是编译报错还是运行报错啊