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)
求大神指点!