0

I am pretty new to java and I am trying to import some classes into my Java project, particularly java.sql and java.io.FileWriter + java.io.BufferedWriter

In my module-info.java, I have added the lines:

module Mynewmodule {
    requires java.sql;
    requires java.io;
}

However, "requires java.io;" throws "java.io cannot be resolved to a module". Any idea on how I can import java.io to later use java.io.FileWriter and java.io.BufferedWriter?

2
  • java.io is not a module. It is a package, and it exists inside the java.base module which is the default one. Therefore, you don't need that line. You only need to import the relevant classes in your source file. Commented Dec 9, 2024 at 17:40
  • Hey thanks, this worked! I swear before I added this, I was getting cannot find type for java.io.FileWriter + java.io.BufferedWriter, but maybe I made a mistake somewhere else. Anyways, thanks for the help and explanation. Commented Dec 9, 2024 at 17:50

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.