B4J Question Console application output shown after command prompt

Alessandro71

Well-Known Member
Licensed User
Longtime User
follow this steps:

1) open B4J (version 10.20 with JDK jdk-19.0.2 as downloaded from the B4J page)
2) File/New.../Console (Non-UI)

a new project will appear with just these lines
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    
End Sub

Sub AppStart (Args() As String)
    Log("Hello world!!!")
End Sub

3) Project/Build Standalone Package
4) open a command prompt and run the executable from the build directory

Bash:
Microsoft Windows [Versione 10.0.26100.4202]
(c) Microsoft Corporation. Tutti i diritti riservati.

C:\Users\aless\Documents\B4A\testconsole\Objects\temp\build>testconsole.exe

C:\Users\aless\Documents\B4A\testconsole\Objects\temp\build>Hello world!!!

the "Hello world" line is printed after the prompt, as the command was executed in background (in unix-like "&" way)
I would expect the following output:
Bash:
C:\Users\aless\Documents\B4A\testconsole\Objects\temp\build>testconsole.exe
Hello world!!!
C:\Users\aless\Documents\B4A\testconsole\Objects\temp\build>

is there any way to fix this?
 

aeric

Expert
Licensed User
Longtime User
Execute the run_debug.bat file.

Alternatively, you can modify the file as following :
run_debug_echo_off.bat:
echo off
cd bin
java.exe @release_java_modules.txt  -m b4j/b4j.example.main
cd ..
and save as "run_debug_echo_off.bat"

Bash:
C:\B4X\Development\helloconsole\Objects\temp\build>run_debug_echo_off.bat

C:\B4X\Development\helloconsole\Objects\temp\build>echo off
Hello world!!!

C:\B4X\Development\helloconsole\Objects\temp\build>

Edit: Exit the B4J app using ExitApplication2(0)
B4X:
Sub AppStart (Args() As String)
    Log("Hello world!!!")
    ExitApplication2(0)
End Sub
 
Last edited:
Upvote 0
Top