Hi,
I have a very simple nonui B4j app that works fine when I call it from "java -jar nonui.jar".
When I build it as exe it behaves strangely.
here's the code. very simple. it processes 3 commands "inc" (which increases an int), "dec" which decrements it, and "quit" to terminate the app .
when I run it from "java -jar nonui.jar" I get the expected result:
when I compile it and run it as exe I get:
basically it seems like in the exe version the reader works after pressing return which also shows the entire path and seems to ignore the instruction Log("Enter command>: ")
any idea?
thanks
I have a very simple nonui B4j app that works fine when I call it from "java -jar nonui.jar".
When I build it as exe it behaves strangely.
here's the code. very simple. it processes 3 commands "inc" (which increases an int), "dec" which decrements it, and "quit" to terminate the app .
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Private reader As TextReader
Public ii As Int
End Sub
Sub AppStart (Args() As String)
Log("Hello world!!!")
Dim Wend As Boolean
Dim sys As JavaObject
If Args.Length >0 Then
Log(Args(0))
End If
sys.InitializeStatic("java.lang.System")
reader.Initialize(sys.GetField("in"))
Wend =True
Do While Wend
Log("Enter command>: ")
Select ReadLine
Case "quit"
Wend = False
ExitApplication2(0)
Case "inc"
ii = ii+1
Log (ii)
Case "dec"
ii = ii-1
Log (ii)
End Select
Loop
StartMessageLoop
End Sub
Sub ReadLine As String
Log("readlineok")
Return reader.ReadLine
End Sub
when I run it from "java -jar nonui.jar" I get the expected result:
INI:
C:\b4a_projects\B4J_Projects\TestConsole\NonUI\Objects>java -jar nonui.jar
Hello world!!!
Enter command>:
readlineok
inc
1
Enter command>:
readlineok
inc
2
Enter command>:
readlineok
dec
1
Enter command>:
readlineok
quit
C:\b4a_projects\B4J_Projects\TestConsole\NonUI\Objects>
when I compile it and run it as exe I get:
INI:
C:\b4a_projects\B4J_Projects\TestConsole\NonUI\Objects\temp\build>nonui
C:\b4a_projects\B4J_Projects\TestConsole\NonUI\Objects\temp\build>Hello world!!!
Enter command>:
readlineok
inc
'inc' is not recognized as an internal or external command,
operable program or batch file.
C:\b4a_projects\B4J_Projects\TestConsole\NonUI\Objects\temp\build>inc
1
Enter command>:
readlineok
inc
'inc' is not recognized as an internal or external command,
operable program or batch file.
C:\b4a_projects\B4J_Projects\TestConsole\NonUI\Objects\temp\build>inc
2
Enter command>:
readlineok
dec
'dec' is not recognized as an internal or external command,
operable program or batch file.
C:\b4a_projects\B4J_Projects\TestConsole\NonUI\Objects\temp\build>dec
1
Enter command>:
readlineok
quit
'quit' is not recognized as an internal or external command,
operable program or batch file.
C:\b4a_projects\B4J_Projects\TestConsole\NonUI\Objects\temp\build>
basically it seems like in the exe version the reader works after pressing return which also shows the entire path and seems to ignore the instruction Log("Enter command>: ")
any idea?
thanks