Java Question Trying to create a lib, Dependencies or programmer problem :D

Myr0n

Active Member
Licensed User
Longtime User
Hi guys,

I am trying to wrap my first library to b4a, everything almost ok, but one of my classes does not work at all.
I am trying to wrap jackcess.2.0.8, why?
because I would like to get from one of my Access table the info of the structure in array, and with the existing wrapped library just return a long string an is difficult to read, and retrieving an array through a new wrapper that will be nice to work in b4a.
my java code works 100%
here it is
B4X:
package dbGetRowInfo;

import java.io.File;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;

public class dbGetRowInfoWithJackcess1x {
    public static Object[] getColumnsInfoInArray(String dbName, String tblName) {
        Object[] tableInfo = null;
            try {
               
                Database db = DatabaseBuilder.open(new File(dbName));
                 tableInfo = db.getTable(tblName).getColumns().toArray();
                
            } catch (Exception e) {
                e.printStackTrace();
            }
            return tableInfo;
        }
   
    public static void main(String[] args) {
        try {
                Object[] tableInfo = getColumnsInfoInArray("C:\\Android\\zb4a-ForeignsProjects\\AccessDb\\DbAccess.mdb","tblLanguage");
                System.out.println(tableInfo.toString());
                        if(tableInfo !=null){
                            for (int x=0; x<tableInfo.length;x++){
                                System.out.println(tableInfo[x].toString());
                            }
                        }
                    } catch (Exception e) {
                e.printStackTrace();
            }
        }
}

and here it is my wrapped code that only works one class
B4X:
package com.example;

//import com.healthmarketscience.jackcess.*;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;

import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.BA.Permissions;

import java.io.*;


@ShortName("getTableInfo")
@Version(1)
@Permissions(values={"android.permission.READ_EXTERNAL_STORAGE"})

public class GetDbInfo {
   
    public static Object[] getColumnsInfoInArray(String dbName, String tblName) {
        Object[] tableInfo = null;
            try {               
                Database db = DatabaseBuilder.open(new File(dbName));
                 tableInfo = db.getTable(tblName).getColumns().toArray();
                
            } catch (Exception e) {
                e.printStackTrace();
            }
            return tableInfo;
        }

    public static Object getColumnsInfoInArray2(String dbName) {
        Object tableInfo;
        try {
           
             tableInfo = dbName + dbName;
            
        } catch (Exception e) {
            e.printStackTrace();
            tableInfo = new Object();
        }
        return tableInfo;
    }
}

this is the output of Simple Library Compiler

Starting step: Compiling Java code.
Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
Loading source file C:\Android\EclipseProjects\MAlexArcLib\src\ca\sicsma\library\GetDbInfo.java...
Constructing Javadoc information...
[-doclet, BADoclet]
[-docletpath, C:\Android\zLibraries\SimpleLibraryCompiler]
[-doclet, BADoclet]
[-docletpath, C:\Android\zLibraries\SimpleLibraryCompiler]
[-bootclasspath, C:\Android\android-sdk\platforms\android-20\android.jar]
[-classpath, C:\Program Files (x86)\Anywhere Software\Basic4android\Basic4android.exe\../libraries\B4AShared.jar;C:\Program Files (x86)\Anywhere Software\Basic4android\Basic4android.exe\../libraries\Core.jar;C:\Android\EclipseProjects\MAlexArcLib\libs\commons-lang-2.6.jar;C:\Android\EclipseProjects\MAlexArcLib\libs\commons-logging-1.1.3.jar;C:\Android\EclipseProjects\MAlexArcLib\libs\jackcess-2.0.8.jar;C:\Android\EclipseProjects\MAlexArcLib\libs\org-apache-commons-lang.jar;C:\Android\EclipseProjects\MAlexArcLib\libs\poi-3.9-20121203.jar;]
[-sourcepath, src]
[-b4atarget, C:\Android\zLibraries\b4a-Libraries\AMyLib02.xml]
[-b4aignore, com.example.hoho]
Ignoring: [com.example.hoho]
starting....
Working with class: com.example.GetDbInfo
finish: C:\Android\zLibraries\b4a-Libraries\AMyLib02.xml

Completed successfully.
*** Don't forget to refresh the libraries list in the IDE (right click and choose Refresh) ***

and these are the dependencies
http://jackcess.sourceforge.net/dependencies.html

and

I am using #AdditionalJar in b4a the my code is

B4X:
    fb.InitializeNewInstance("ca.sicsma.library.GetDbInfo", Null)
    Log(fb.RunMethod("getColumnsInfoInArray2", Array("/Northwind.mdb")))
    Log(fb.RunMethod("getColumnsInfoInArray", Array("/Northwind.mdb","tblLanguage")))

the error is

B4X:
** Activity (main) Create, isFirst = true **


/Northwind.mdb/Northwind.mdb


java.lang.NoClassDefFoundError: com.healthmarketscience.jackcess.DatabaseBuilder
    at com.example.library.GetDbInfo.getColumnsInfoInArray(GetDbInfo.java:23)
    at b4a.example.main._activity_create(main.java:326)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at b4a.example.main.afterFirstLayout(main.java:98)
    at b4a.example.main.access$100(main.java:16)
    at b4a.example.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5042)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)


    at dalvik.system.NativeStart.main(Native Method)

I google it the error and in resume say "dependencies error"

Note that all the dependencies I copied to my library folders.

Could you help me please.

Thank you so much
 

Myr0n

Active Member
Licensed User
Longtime User
@DependsOn

Thank you guys
 
Top