Check two things

Eclipse preferences

  1. Check your Eclipse preferences: Java -> Installed JREs
  2. The one that you're using should be marked and it should be a JDK not just a JRE.

Project build path

  1. Also check your project's build path: Right click on the project -> Properties -> Java Build Path
  2. Check in the libraries folder whether the JRE System Library is present and ...
  3. If not add it using Add library -> JRE System Library and then select the correct one (from an installed JDK).
Answer from 1218985 on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › io › File.html
File (Java Platform SE 8 )
April 21, 2026 - An absolute pathname is complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in the java.io package always resolve relative ...
🌐
W3Schools
w3schools.com › java › java_files.asp
Java Files
To use the File class, create an object of the class, and specify the filename or directory name: import java.io.File; // Import the File class File myObj = new File("filename.txt"); // Specify the filename
Discussions

android - Eclipse: "The import java.io cannot be resolved" - Stack Overflow
I just appeared during editing in another file, the same code had worked before. For me, all settings were correct and none of the above tricks worked. What I then did was completely removing the import command import java.io.Closeable;, saving the file, adding the same import command back ... More on stackoverflow.com
🌐 stackoverflow.com
How can I read all files in a folder from Java? - Stack Overflow
How can I read all the files in a folder through Java? It doesn't matter which API. More on stackoverflow.com
🌐 stackoverflow.com
What does import.java.io.*; mean?
Import all of the classes of namespaces that fall under java.io that are needed in this class, i.e. java.io.Console which can print and take user input More on reddit.com
🌐 r/learnjava
4
2
October 1, 2020
[Java] need help understanding File and Data Input/Output Stream classes
The official tutorial has a whole section on IO Streams. For specific things about the classes and their methods you can always check the API documentation for java.io. More on reddit.com
🌐 r/learnprogramming
5
2
February 26, 2014
🌐
GeeksforGeeks
geeksforgeeks.org › java › file-class-in-java
Java File Class - GeeksforGeeks
November 3, 2025 - Example 1: Program to check if a file or directory physically exists or not. Java · import java.io.File; // Displaying file property class CheckFileExist { public static void main(String[] args){ // Accept file name or directory name through // command line args String fname = args[0]; // pass the filename or directory name to File // object File f = new File(fname); // apply File class methods on File object System.out.println("File name :" + f.getName()); System.out.println("Path: " + f.getPath()); System.out.println("Absolute path:" + f.getAbsolutePath()); System.out.println("Parent:" + f.
🌐
CodeGym
codegym.cc › java blog › java io & nio › java.io.file class
Java.io.File Class
June 6, 2022 - The File class is defined in the java.io package and it doesn’t work directly with streams. Java File class is to manage information about files and directories. As you know, at the operating system level, files and directories are different objects. However in Java, they both are described by the same File class.
🌐
Tutorialspoint
tutorialspoint.com › java › java_files_io.htm
Java - Files and I/O
Failure indicates that the path specified in the File object already exists, or that the directory cannot be created because the entire path does not exist yet. The mkdirs() method creates both a directory and all the parents of the directory. Following example creates "/tmp/user/java/bin" directory − ... import java.io.File; public class CreateDir { public static void main(String args[]) { String dirname = "/tmp/user/java/bin"; File d = new File(dirname); // Create directory now.
🌐
W3Schools
w3schools.com › java › java_files_read.asp
Java Read Files
To get more information about a file, use any of the File methods: import java.io.File; // Import the File class public class GetFileInfo { public static void main(String[] args) { File myObj = new File("filename.txt"); if (myObj.exists()) { ...
Find elsewhere
🌐
GitHub
github.com › openjdk › jdk › blob › master › src › java.base › share › classes › java › io › File.java
jdk/src/java.base/share/classes/java/io/File.java at master · openjdk/jdk
package java.io; · import java.net.URI; import java.net.URL; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.nio.file.FileStore; import java.nio.file.FileSystems; import java.nio.file.Path; import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; import jdk.internal.util.StaticProperty; ·
Author   openjdk
🌐
DataFlair
data-flair.training › blogs › java-file-class
Java File Class (java.io.File) - Uncover the Methods and Constructors used in it! - DataFlair
February 10, 2018 - Notice that the last file was already present from the previous examples. That is why the file is executable. ... package com.dataflair.javafileclass; import java.io.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-files-nio-files-class
Java Files - java.nio.file.Files Class | DigitalOcean
August 4, 2022 - It traverses the directory at specified path recursively and returns the starting file. package com.journaldev.examples; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.FileVisitor; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; /** * Java Files walk file tree example * * @author pankaj * */ public class FilesWalkFileTreeExample { public static void main(String[] args) { Path path = Paths.get("D:/pankaj"); try { Files.walkFileTree(path, new FileVisitor<Path>() { @Overr
🌐
GitHub
github.com › openjdk-mirror › jdk7u-jdk › blob › master › src › share › classes › java › io › File.java
jdk7u-jdk/src/share/classes/java/io/File.java at master · openjdk-mirror/jdk7u-jdk
package java.io; · import java.net.URI; import java.net.URL; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.util.List; import java.util.ArrayList; import java.security.AccessController; import java.security.SecureRandom; import java.nio.file.Path; import java.nio.file.FileSystems; import sun.security.action.GetPropertyAction; ·
Author   openjdk-mirror
🌐
Quora
quora.com › What-does-import-Java-io-*-actually-means-in-Java-programming
What does import.Java.io.*; actually means in Java programming? - Quora
Answer (1 of 6): It means you import the class which is include in Java Input Output package those class which is used in our implementation class like FileOutputStream FileReader etc.
🌐
Tutorialspoint
tutorialspoint.com › java › io › index.htm
Java.io package Tutorial
This package is very useful as it provides streams to handle input from various sources like keyboard, file system, network etc. On similar patterns, this package has stream classes to write to various kind of sources. This reference will take you through simple and practical methods available in java.io package. Being an inbuilt package of Java, we're not required to download any external library for java.io package and its all classes can be imported using following syntax:
🌐
Great Learning
mygreatlearning.com › blog › it/software development › file handling in java
File Handling in Java (Read, Write and Create Java Files)
January 22, 2025 - This class does not directly read or write data but helps manage file metadata and operations like creation, deletion, and inspection. Suggested Read: OOPs Concepts in Java with Examples ... Learn Java the right way! Our course teaches you essential programming skills, from coding basics to complex projects, setting you up for success in the tech industry. ... import java.io.File; public class FileExample { public static void main(String[] args) { try { // Create a File object with the specified path File file = new File("example.txt"); // Check if the file does not exist, then create it if (file.createNewFile()) { System.out.println("File created: " + file.getName()); } else { System.out.println("File already exists."); } } catch (Exception e) { // Handle any potential exceptions System.out.println("An error occurred."); e.printStackTrace(); } } }
🌐
DataCamp
datacamp.com › doc › java › read-files
Java Read Files
The Files class provides a straightforward way to read all lines of a file into a List<String>. This method is efficient for smaller files. import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ScannerExample { public static void main(String[] args) { try (Scanner scanner = new Scanner(new File("example.txt"))) { while (scanner.hasNextLine()) { System.out.println(scanner.nextLine()); } } catch (FileNotFoundException e) { e.printStackTrace(); } } }
🌐
Tutorialspoint
tutorialspoint.com › java › java_file_class.htm
Java - File Class
The following example demonstrates how to use the File object in a Java program − · package com.tutorialspoint; import java.io.File; public class FileDemo { public static void main(String[] args) { File f = null; String[] strs = {"test1.txt", "test2.txt"}; try { // for each string in string array for(String s:strs ) { // create new file f = new File(s); // true if the file is executable boolean bool = f.canExecute(); // find the absolute path String a = f.getAbsolutePath(); // prints absolute path System.out.print(a); // prints System.out.println(" is executable: "+ bool); } } catch (Exception e) { // if any I/O error occurs e.printStackTrace(); } } }
🌐
guvi.in
studytonight.com › java › file-handling.php
Java File Class
This method creates a new file if file is not already exist. See the example below. import java.io.File; import java.io.IOException; public class FileCreateDemo1 { public static void main(String[] args) { try { File Obj = new File("FileDemo.txt"); if (Obj.createNewFile()) { System.out.println("******File created******"); System.out.println("Name of the file = " + Obj.getName()); } else{ System.out.println("File already exists."); } } catch (IOException e){ e.printStackTrace(); } } }