1

I'm trying to import the CSVReader into my Java project, but when I tried to build the project, it says that 'The import au cannot be resolved'.

I've added the opencsv-3.3.jar into my build path, and have imported the following in my source code.

import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy;
import au.com.bytecode.opencsv.bean.CsvToBean;

What else could be missing or wrong that causes this issue?

3
  • 3
    That jar just uses 'com.opencsv' as the package name. Commented Apr 17, 2015 at 7:19
  • you are not importing it correctly or its not in class path. Commented Apr 17, 2015 at 7:23
  • Yes, it is working now. Didn't realized that they are using different package. Commented Apr 17, 2015 at 7:38

1 Answer 1

2

You need to take the rigth Jar. For example you can take it from here mvnrepository.com

This contains the packages au.com.bytecode.opencsv and the repository is located at https://github.com/EmergentOrder/opencsv which is a fork of https://code.google.com/p/opencsv/

The project on https://code.google.com/p/opencsv/ provide the packages com.opencsv

Depending which project you want to use. Maybe changing the package name in the import statement would fix it (when opencsv-3.3.jar is the Jar you need to use).

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I've found the difference and it is working now. Originally thought that the opencsv-3.3.jar is just a newer version as compared to opencsv-2.4.jar
For reading a CSV file without adding a jar you can look here: mkyong.com/java/how-to-read-and-parse-csv-file-in-java

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.