### Create Non-UI Terminal App

To build a Non-UI terminal app, create a B4J Non-UI Project and use JavaObject to access the standard input stream.
Below is an example of a simple terminal app, which handles 3 commands date, time, dt.
Example Simple Terminal App
`Sub Process_Globals
Private CAPPTITLE As String = "B4JHowTo Simple Terminal App v20141118"
Private CAPPAUTHOR As String = "by Robert W.B. Linn"
' Command reader from the textline
Private cmdreader As TextReader
End Sub`
`Sub AppStart (Args() As String)
Log(CAPPTITLE & CRLF & CAPPAUTHOR)
Dim joSys As JavaObject
' The Java System class contains several useful class fields and methods. It cannot be instantiated.
joSys.InitializeStatic("java.lang.System")
Try
' The "standard" input stream. This stream is already open and ready to supply input data.
' Typically this stream corresponds To keyboard input OR another input source specified by the host environment OR user.
cmdreader.Initialize(joSys.GetField("in"))
'
Log("Enter Command: date, time, dt")
Dim cmd As String = ReadLine.ToLowerCase
Log("Command entered: " & cmd)
Log("Result:")
Select cmd
Case "date"
Log(DateTime.Date(DateTime.Now))
Case "time"
Log(DateTime.Time(DateTime.Now))
Case "dt"
Log(DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now))
Case Else
Log("Invalid command entered!")
End Select
Log("End App")
Catch
Log(LastException.Message)
End Try
End Sub`
' Read the line from the command line
`Sub ReadLine As String
Return cmdreader.ReadLine
End Sub`

Changed: 2018-06-07 09:07, Category: Application, File: T6C159M1151.htm, ID: 1151