问题描述
- 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 Fileat nmd.FileHello.main(FileHello.java:8)
求大神指点!
解决方案
import java.io.File
解决方案二:
java中String类的构造函数
java中String类的构造函数
java中String类的构造函数
----------------------
解决方案三:
是编译报错还是运行报错啊
时间: 2024-09-12 22:07:34