错误:类型com.sun.java.util.jar.pack.Package不可见(Error: The type com.sun.java.util.jar.pack.Package is not visible)

当我尝试创建一个程序来读取目录及其内容时,我的代码中有这个错误。

com.sun.java.util.jar.pack.Package类型不可见

我的代码现在很简单:

/** * */ package exercice5; import com.sun.java.util.jar.pack.Package.File; /** * @author * */ public class ListFilesAndDirectories { /** * */ public ListFilesAndDirectories() { // TODO Auto-generated constructor stub } /** * @param args */ public static void main(String[] args) { File myfile = new File("."); } }

我不明白问题在哪里,因为我认为我已经导入了正确的File包。

有人理解这个问题吗?

I have this error in my code when I tried to create a program to read directories and its content.

The type com.sun.java.util.jar.pack.Package is not visible

My code is simple for now:

/** * */ package exercice5; import com.sun.java.util.jar.pack.Package.File; /** * @author * */ public class ListFilesAndDirectories { /** * */ public ListFilesAndDirectories() { // TODO Auto-generated constructor stub } /** * @param args */ public static void main(String[] args) { File myfile = new File("."); } }

I do not understand where the problem is since I think that I have imported the right File package.

Does someone understand this issue?

最满意答案

你的进口是错误的。 更换

import com.sun.java.util.jar.pack.Package.File;

import java.io.File;

Your import is wrong. Replace

import com.sun.java.util.jar.pack.Package.File;

with

import java.io.File;

更多推荐