Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+17 votes

InputStream inputStream =
Card.class.getResourceAsStream("/GymSoftwarePics/DEMO1.csv");

            if (inputStream != null) {
                beans = new CsvToBeanBuilder(new FileReader("src/main/resources/GymSoftwarePics/DEMO1.csv"))
                        .withType(Card.class).build().parse();
            } else {
                System.err.println("CSV file not found in the classpath.");
            }

That is the code I have right now, and it is throwing a ClassNotFoundException at the withType(Card.class) line. However, it doesn't throw the same exception in the inputStream line(yes I know it doesn't do anything). Does anyone know why it is throwing a class not found exception? the class does exist and is called Card

asked in CSC305 Fall 2023 by (1 point)
edited by
+1

Can you edit your question to include the full error message? E.g. Is it a ClassNotFoundException, or a FileNotFoundException?

1 Answer

+2 votes

I have figured it out, I was misreading the exception message and needed to add a requirement to the module. I had to add java.sql if anyone else runs into this problem

answered by (1 point)
...