Originally I had a java.io.File class in a jar in the classpath, which didn’t have a separatorChar property. So I ran into a problem where the following code block runs:
import java.io.File;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("separatorChar= " + File.separatorChar);
}
}
But I changed the import statement as follows:
import java.io.*;
and then I get an error basically stating that File.separatorChar cannot be found.
What I believe is happening is import java.io.* is using a class that’s in a jar in the classpath, whereas import java.io.File is specifically using the File class that comes with Java.
The question here is why does import java.io.File work while java.io.* does not?
As EJP commented on the original question,