1

I'm a beginner with java. Today I've tried to make an application to editing mdb databases. I decided to use Jackcess but I always have some errors. I'm a beginner so I use text editor to write a code and then I use javac from cmd (it's not the most effective solution but it allows you to better understand the whole idea about java). My problem is that I can't make any application which will be compilable and work correctly.

Example_1: Create an Access database file (.mdb or .accdb) using Java in this link Sarath Kumar Sivan tells that you need to install Jackcess, commons-logging, commons-lang jars, and try the code. I downloaded these jars. Then I moved them to this directory:

C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext

After it I tried to compile the code but I got this error:

JackcessLibrary.java:20: error: cannot find symbol
return Database.create(new File(databaseName));
               ^
symbol: method create(File)
location: interface Database
1 error

I have no idea what it does mean.

Example_2: on the official page of Jackcess you can read that you can start with simple command:

Database db = DatabaseBuilder.open(new File("mydb.mdb"));

so I wrote this:

import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.*;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.TableBuilder;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Types;

class Jackcess2 {
    public static void main (String[] args) {
        Database db = DatabaseBuilder.open(new File("mydb.mdb"));       
    }
}

which gave me this error:

Jackcess2.java:21: error: unreported exception IOException; must be caught or declared to be thrown
Database db = DatabaseBuilder.open(new File("mydb.mdb"));
                                  ^
1 error

so I edited it to this:

import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.*;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.TableBuilder;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Types;

class Jackcess2 {
    public static void main (String[] args) {
        try {
            Database db = DatabaseBuilder.open(new File("Uruchom.odb"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("Done.");        
    }
}

and now I can compile it but after run it I have this message:

Error: Could not find or load main class Jackcess2.java

I suppose that I need to include Jackcess class but I have no idea how to do it. I've never seen anything like that before.

I've tried other various ways to use Jackcess but nothing work properly. Can you explain me how to use Jackcess and what I've missed?

Community
  • 1
  • 1
danski88
  • 85
  • 1
  • 7
  • Successful compilation of your `.java` source will produce a `.class` file, which is what you will actually be executing. From your source code it looks like the resulting `.class` file would be "Jackcess2.class" which you would execute using the command `java Jackcess2`. (Note that you do not supply the `.class` file extension when launching the application.) – Gord Thompson Jan 22 '17 at 23:42
  • I've made 1 mistake: there should be: Error: Could not find or load main class Jackcess2.java ('two' after Jackcess). Gord Thompson: my situation is exactly as you wrote: I had Jackcess2.java, then I performed compilation by this command: javac Jackcess2.java, and then I wanted to run the application by command: java Jackcess2 but I have this message: Error: Could not find or load main class Jackcess2.java – danski88 Jan 24 '17 at 20:50
  • Duplicate of: [What does “Could not find or load main class” mean?](https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean) – Mark Rotteveel Jun 08 '19 at 15:34
  • Also the problems you initially had are an indication that maybe you should first familiarize yourself with the basics of Java before trying to dive into using a library like Jackcess. – Mark Rotteveel Jun 08 '19 at 15:36

0 Answers0