B4J Question Compiled program won't start

oldeast

Active Member
Licensed User
Longtime User
I am running the B4j packager with the IDE and get no errors. On Win 10, the program seems to install but there is no .."program installed " message at completion. The program shortcut appears but the program won't run. The jar file runs ok too.
The project uses an SQLite database and I move that to a readable location. I tried renaming the program and restarting win after install .. anyone have any suggestions where to start looking...
thanks...
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
A little trick i did was to write a Try Catch Block in the appstart then in the catch part i requested the app to create a small txt file with the lastexception line.

A bit dumb but worked for me.
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
I used Erel's code to create the log file but it's empty ...
B4X:
 AppStart (Form1 As Form, args() As String)
    Try
        MainForm=Form1
        MainForm.RootPane.LoadLayout("Main")
        MainForm.SetFormStyle("DECORATED")
        MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "TabPane.css"))
        MainForm.Title="Collection Management System"
        TabPane1.StyleClasses.Add("tab-pane")
        TabPane1.LoadLayout("ObjDetailsTab", "Details")
        TabPane1.LoadLayout("ObjProvTab", "History/Provenance")
        TabPane1.LoadLayout("ObjSignTab", "Significance")
        TabPane1.LoadLayout("ObjImageTab", "Image")
       
        Toast.Initialize("Toast")
        Toast.ToastIconSize32x32
        Toast.ToastDuration = 6 'Toast.TOAST_LONG_DELAY
        Toast.ToastTextLocation = Toast.TEXT_CENTER
        Toast.ToastLocation= Toast.TOAST_CENTER_RIGHT
        Toast.ToastMessageColor = fx.Colors.Green


    'open database and show Objects in Tableview
    'Log(GetSystemProperty("user.home",""))
   
    Utils.CreateSqlDatabase
    SQL1.InitializeSQLite(Utils.DBaseFilePath, "scm.db3", False)
    strQuery = "SELECT _id[ID],  Accession[Accn No.], Name[Object Name] FROM Objects Order BY Name;"
    DBUtils.ExecuteTableview(SQL1,strQuery,Null,0,tblObjEdit)
    tblObjEdit.SetColumnVisible(0,False)
    tblObjEdit.SetColumnWidth(1,80)
    tblObjEdit.SetColumnWidth(2,200)
   
   
    'load search combo box
    cboSearch.Value="ALL"
    cboSearch.Items.AddAll(Array As String("ALL", "Accession", "Name", "AccBy", "AccDate", "Aesthetic","CondNote", "Condition", "CulturalValue","CurrentLoc","Conservator", "ConsDate","DateMade", "Description", "Export", "History", "Historic","Loan", "ObjectSet", "ObjectType", "PrimaryClass","ProvCount", "Scientific","SecondClass","Social", "Storage"))

    'Load units
    strQuery="Select Units from SetUp Where _id=1"
    Dim m As Map
    m = DBUtils.ExecuteMap(SQL1, strQuery, Null)
    lblUnits.Text=m.Get("units")
    Units=lblUnits.Text
   
    'splash screen - title screen -
        Splash.Initialize("frmStartup", 500, 500)
        Splash.RootPane.LoadLayout("Startup.bjl")
        Splash.Resizable=False
        Splash.SetFormStyle("UNDECORATED")
        lblName.Text=ProgName
        lblVersion.Text=ProgVersion
        lblCopyright.text=Copyright
        Timer1.Initialize("Timer1", 2000)
        Splash.show
        Timer1.Enabled=True   
Catch
    LogDebug(Utils.DBaseFilePath)
    RedirectOutput(Utils.DBaseFilePath, "logs.txt")   
End Try   
   

End Sub   
Sub RedirectOutput (Dir As String, FileName As String)
   '#if RELEASE
   Dim out As OutputStream = File.OpenOutput(Dir, FileName, True) 'Set to True to append the logs
   Dim ps As JavaObject
   ps.InitializeNewInstance("java.io.PrintStream", Array(out, True, "utf8"))
   Dim jo As JavaObject
   jo.InitializeStatic("java.lang.System")
   jo.RunMethod("setOut", Array(ps))
   jo.RunMethod("setErr", Array(ps))
   '#end if

End Sub 
Sub Timer1_tick   
    Splash.Close
    MainForm.show

 End Sub
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
File.copy(File.DirApp,"data/scm.db3",DBaseFilePath,"scm.db3")

Log(DBaseFilePath)

C:\Users\Graham\SCM\data
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
B4X:
Sub DBFilePath
    Dim str1 As String
   
    str1 = GetSystemProperty("user.home","")
   
    'check if Db already created
       
        If Not(File.IsDirectory(str1, "SCM")) Then
            File.MakeDir(str1, "SCM")
            InitialFilePath = File.Combine(str1, "SCM")
        Else
            InitialFilePath = File.Combine(str1, "SCM")       
        End If
   
    ' DBase File Path
            If Not(File.IsDirectory(InitialFilePath, "data")) Then
                File.MakeDir(InitialFilePath, "data")
                DBaseFilePath = File.Combine(InitialFilePath, "data")
            Else
                DBaseFilePath = File.Combine(InitialFilePath, "data")       
            End If
    File.copy(File.DirApp,"data/scm.db3",DBaseFilePath,"scm.db3")
   
Log(DBaseFilePath)
Where is the code that sets DBaseFilePath?
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
Ok...so I will copy the database to that C:\Users\Graham\AppData\Roaming\SCM
Thanks
Erel
InitialFilePath = File.Combine(File.DirApp, "data")
Log(InitialFilePath)
Log(File.DirData("CMS"))
File.copy(InitialFilePath,"cms.db3",File.DirData("CMS"),"cms.db3")
 
Last edited:
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
I don't think its my project that's at fault, as I can't compile a simple single main form program.
I am running packager in the IDE, getting no errors and have installed Inno..
I saw a suggestion to add a path to Inno, added a path in win10 C:\Program Files (x86)\Inno Setup 5 and that has not helped.
Any suggestions appreciated.
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
apologies..the Objects folder wasn't transferred to the zip file for some reason
I took out the code to transfer the db from File.DirApp to File.DirData as data is only read in the cut down.
 

Attachments

  • test1.zip
    62.6 KB · Views: 229
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Your last project compiles without problems and the program starts.



I had to change this:
#AdditionalJar: lib\sqlite-jdbc-3.8.11.2
to this:
#AdditionalJar: sqlite-jdbc-3.8.11.2
because I load all additional libraries in an AdditionalLibraries folder.
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
thanks very much..I will run the full project, great to have a reply on the weekend!
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
Klaus, thanks for your answer.
I had also made another error by placing my database in a a subfolder Objects/data.
This would not run after it was compiled.
Graham
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…