B4J Question [Solved] Change path to config file when exe is created with Integrated B4JPackager11

kgf

Member
Licensed User
Longtime User
Hi
I have a modified version of JRDC with a GUI to run on windows laptops. But I would like to package it as an exe.
The code below returns the file which is the same folder as the jar, which is ok when using a bat file but when packaged the config file needs to be put in the bin folder with the jar

B4X:
Return File.ReadMap(File.DirApp, "config.properties")

Is it possible to change this so that it will find the config file in the folder with the exe as below, so the config and other files can be put with the .exe rather than having to go in the bin folder.

1657068636503.png


Thanks
 

kgf

Member
Licensed User
Longtime User
That works thanks with the config file though I cant figure out how to get the path to the Access DB file at the same location as the config.
B4X:
strFilePath = "jdbc:ucanaccess://" & File.DirApp.Replace("\","/") & "/" & config.Get("db_name") & ";memory=True"
Not sure how to include the ../ in this

Noted re jServer in UI apps, will avoid in the future, but it has been working fine for current use.
I work on conservation projects in many cases without internet and I have set up the UI to give a bit more feedback when running JRDC than just the command window.
We are using phones syncing to an Access database on a laptop over WiFi and It has been working on ships, sub Antarctic bases and field huts with 12v routers.
We just run the server(bat) when we need to sync and then close it again.
Took a while to find a solution that can be used and also changed in the field, so many thanks
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

kgf

Member
Licensed User
Longtime User
Working thank you

B4X:
    #IF RELEASE
        strFolderPath = File.GetFileParent(File.DirApp).Replace("\","/")
        strFilePath = "jdbc:ucanaccess://" & strFolderPath & "/" & config.Get("db_name") & ";memory=True"
    #ELSE
        strFolderPath = File.DirApp
        strFilePath = "jdbc:ucanaccess://" & File.DirApp.Replace("\","/") & "/" & config.Get("db_name") & ";memory=True"
    #END IF

I have had a quick look at CloudKS but we are offline mostly and need to run reports etc from the Access database. And it might be a a few months before a laptop is online. so with JRDC we can use phones and laptops to sync data anywhere! And Access gives us a file based database we can put on a USB and then on a boat and send to a user somewhere else.

Thanks again
 
Upvote 0

kgf

Member
Licensed User
Longtime User
I will just need to remember!
but planning on packaging as standalone exe mostly
 
Upvote 0
Top