0

I want to use this code snippet from here https://jackcess.sourceforge.io:

Database db = DatabaseBuilder.open(new File("my.mdb"));
new ImportUtil.Builder(db, "Imported").importResultSet(resultSet);
db.close();

like this:

import java.io.File;
// import java.util.Builder;
public class ReadFile {
    public static void main(String[] args) {
        Database db = DatabaseBuilder.open(new File("blank.mdb"));
        new ImportUtil.Builder(db, "Imported2").setDelimiter(",").importFile(new File("testDf.csv"));
        db.close();
    }
  }

I am new to java so not so sure about how to import libraries. Currently, I get an error that:

java:9: error: cannot find symbol
        Database db = DatabaseBuilder.open(new File("blank.mdb"));
    symbol:   variable DatabaseBuilder
    location: class ReadFile

java:10: error: package ImportUtil does not exist
    new ImportUtil.Builder(db, "Imported2").setDelimiter(",").importFile(new File("testDf.csv"));

I also tried import java.util.Builder;but i would still get the same error

x89
  • 2,798
  • 5
  • 46
  • 110

1 Answers1

0

Make sure that the ImportUtil from jackcess is on your classpath. There are tons of Tutorials on how to add a library to your project out there.

In case you use f.e. Maven just import this into your pom.xml file as a dependency.

<dependency>
<groupId>com.healthmarketscience.jackcess</groupId>
<artifactId>jackcess</artifactId>
<version>4.0.1</version>
</dependency>

Otherwise please provide more details which ide you use and how you want to build your application.

eckad158
  • 385
  • 6
  • 19
  • I just have a single ```file.java```that I am using in VSCode. No separate pom.xml file for now – x89 Mar 11 '22 at 10:15
  • Here is how java dependencies are managed in VS Code. https://code.visualstudio.com/docs/java/java-project#_dependency-management – eckad158 Mar 11 '22 at 10:21
  • this is quite confusing, especially because idont see all the things displayed in the tutorial. What if I am not using any IDE? Is it possible to manually create a class path file? how would that look like? https://stackoverflow.com/a/54535301/12304000 – x89 Mar 11 '22 at 12:56