B4J Question jar to run in windows

paul allen

Member
Licensed User
Longtime User
my last windows computer i use to link jar file in windows link and it ran the program, i since got new computer and it will not do that now. i've tried to put a path to jave but still nothing, which java program to link the jar to run????? thanks.
 

OliverA

Expert
Licensed User
Longtime User
It was only when I wanted to make a standalone exe file that it didn't not work.
1) I'm using my example UCanAccess demo from here: https://www.b4x.com/android/forum/t...emo-works-under-b4j-see-notes.121546/#content
2) I'm using B4J version 8.90
3) I've downloaded Java 11 from here: https://b4xfiles-4c17.kxcdn.com/jdk-11.0.1.zip (this link is provided by https://www.b4x.com/b4j.html). I've unpacked the files under C:\OpenJDK\jdk-11.0.1 . In B4J, the path for javac.exe is set to C:\OpenJDK\jdk-11.0.1\bin\javac.exe
Notes: This is the only JDK 11 version I have ever used. I've also installed a JDK 14 version that was provided here https://www.b4x.com/android/forum/t...lest-way-to-distribute-ui-apps.99835/#content.
4) I've downloaded the zip file provided in https://www.b4x.com/android/forum/threads/opening-ms-access-databases-mdb.107963/#content

Steps taken:
a) Unzip the demo from 1) above. Project is located under B4XPagesUCanAccessLight2
b) Unpack the zip file from 4). Place the .jar files in the AdditionalLibraries folder as configured in the B4J IDE. Place the text files under B4XPagesUCanAccessLight2\B4J\Files
c) open the B4J project under B4XPagesUCanAccessLight2
d) In the Files tab, do a right click and select Sync (to properly display the .txt files added in step b)
e) In the Main module, change
B4X:
    #AdditionalJar: ucanaccess-4.0.4
    #AdditionalJar: commons-lang-2.6
    #AdditionalJar: commons-logging-1.1.3
    #AdditionalJar: hsqldb-2.3.1
    #AdditionalJar: jackcess-2.1.11
to
B4X:
    'Files and directives taken from here:
    'https://www.b4x.com/android/forum/threads/opening-ms-access-databases-mdb.107963/#content
    #AdditionalJar: ucanaccess-5.0.0
    #AdditionalJar: commons-lang3-3.8.1
    #AdditionalJar: commons-logging-1.2
    #AdditionalJar: hsqldb-2.5.0
    #AdditionalJar: jackcess-3.0.1-B4J
    #IgnoreWarnings: 15
f) Run example in Release mode. If everything done correctly so far, it should run correctly
g) In the Project menu of the IDE pick Build Standalone Package
h) the build folder should open with the generated executable file. It should work (it did for me)
i) for the rest, see @Nicola Ciaramellano's post #6 above

Update:
Just tested it successfully with JDK 14 provided here https://www.b4x.com/android/forum/t...lest-way-to-distribute-ui-apps.99835/#content
 
Last edited:
Upvote 0

BigBoss123

Member
Licensed User
Longtime User
Well what you have shown it correct but not for a password database.

I followed once again with new installations and followed your ordered list of #additional.jars.
And then with all the required #additional.jars for an encrypted database after your list of #additional.jar
the stand alone package worked!!!!

So it seems that the list of #addtional.jars need to be in a specific order and the encrypted #additional jars should follow.
To help anyone else trying to read an encrypted MS-Access database I am listing the necessary requirements.
Firstly the additional. Jars
B4J Main:
    #AdditionalJar: ucanaccess-5.0.0
    #AdditionalJar: commons-lang3-3.8.1
    #AdditionalJar: commons-logging-1.2
    #AdditionalJar: hsqldb-2.5.0
    #AdditionalJar: jackcess-3.0.1-B4J   
    #Additionaljar: sqlite-jdbc-3.7.2
    ' MS ACCESS ENCRYPTED
    #AdditionalJar: jackcess-encrypt-3.0.0
    #AdditionalJar: bcprov-jdk15on-154.jar

    #IgnoreWarnings: 15

Secondly you need to add the following at the end of B4J_main

B4X:
if JAVA
import java.io.File;
import java.io.IOException;
import net.ucanaccess.jdbc.JackcessOpenerInterface;
    import com.healthmarketscience.jackcess.CryptCodecProvider;
    import com.healthmarketscience.jackcess.Database;
    import com.healthmarketscience.jackcess.DatabaseBuilder;
    import java.sql.SQLException;

public static class MyOpener implements net.ucanaccess.jdbc.JackcessOpenerInterface {
public Database open(File fl,String pwd) throws IOException {
   Database db = new DatabaseBuilder(fl).setCodecProvider(new CryptCodecProvider(pwd)).open();
   return db;
        }
    }
#End If

to access the database the SQL file should look be as follows
B4X:
    AccDBName = "storage.accdb"
    AccDBPath = File.Combine("C:/waistorage", AccDBName)
    
    'initialize the database
    SQL1.Initialize2("net.ucanaccess.jdbc.UcanaccessDriver", "jdbc:ucanaccess://"& AccDBPath & ";memory=true;showSchema=true;openExclusive=true;immediatelyReleaseResources=true;jackcessOpener=b4j.Locations.main$MyOpener"$,"", "*Password*") 'change packagename, path, user as password as needed

thanks everybody for your help
 
Upvote 0
Top