Running BoxLang

BoxLang and the Multiverse!

Please check out our installation page to make sure you install the right runtime you want to deploy on. We are assuming you have it installed and boxlang and boxlang-miniserver are in your machine's path.

The script for *nix/Mac is boxlang

The script for Windows is boxlang.bat

BoxLang Home

By default, once you execute a boxlang binary it will look for a BOXLANG_HOME environment variable so it can be used as the home for the OS runtime. If you don't provide one, then by default, it will use the currently logged-in user's home folder + .boxlang


This is important because inside of the home folder, you can have several folders and files by convention that will be used for the runtime execution.



Where all the compiled classes will be stored


You can place any *.jar files here, and they will be loaded into the runtime at startup. This is a great place to put third-party jars that will be available at runtime.


All log files will be stored here


Here is where the BoxLang modules are installed and will be available for the entire operating system binary.


The runtime configuration file. Here is where you can configure all the settings, caches, datasources, compiler information, and so much more.

Start the REPL

The first thing you can do is start up the BoxLang REPL, make sure the insaller has added your installation directory to the PATH system variable.


You can run one-off expressions from the REPL like so:

Enter an expression, then hit enter.
Press Ctrl-C to exit.

BoxLang> 2+2

BoxLang> dateFormat( now(), "full" )
Wednesday, March 13, 2024

BoxLang> "brad".ucase().reverse()

BoxLang> a=3

BoxLang> b=5

BoxLang> a*b

BoxLang> ["luis","gavin","jorge"].map( name->name.ucFirst() )
[Luis, Gavin, Jorge]

Press Ctrl-C to exit the REPL.

Please note that the REPL remembers state, so you can use the variables you declare and build a mini-program with it.

Executing a File

You can also use the boxlang binary to execute BoxLang or even CFML code. You can pass a second argument to the binary and it can be a relative (to the current directory you are on) or an absolute path to a file that you wish to execute.

Allowed files are:

  • *.bx - A BoxLang class with a main( args=[] ) method

  • *.bxs - A BoxLang script file

  • *.bxm - A Boxlang markup template file

  • *.cfs - A CFML script file

  • *.cfm - A CFML markup template file

Modify the same command you run above to execute the REPL but add a file path to the end. It can be absolute or relative to the current working directory.

boxlang task.bx
boxlang myscript.bxs
boxlang mytemplate.bxm

boxlang /full/path/to/test.bxs
boxlang /full/path/to/Task.bx

Producing Output

As you navigate all the built-in functions and capabilities of BoxLang, let's learn how to produce output to the system console.

  • printLn() - Print with a line break

  • print() - Print with no line break

  • writeOUtput() - Writes to the output buffer (Each runtime decides what it's buffer is. The CLI is the system output, the Web is the HTML response buffer, etc)

println( "Time is #now()#" )

I get the output:

╰─ boxlang test.bxs
Time is {ts '2024-05-22 22:09:56'}

Hooray! You have executed your first script using BoxLang. Now let's build a class with a main( args=[] ) convention. This is simliar to Java or Groovy.


        function main( args=[] ){

                println( "Task called with " & arguments.toString() )



You can now call it with zero or more arguments!

╰─ boxlang Task.bx
Task called with {ARGS=[]}

╰─ boxlang Task.bx boxlang rocks
Task called with {ARGS=[boxlang, rocks]}

One Off Code Execution

So, to give a quiet example of the -c flag here’s running some one-off code.

boxlang -c "2+2"

This assumes script, not templating tags.

Piping code

You can also pipe statements into the BoxLang binary for execution as well. This assumes script, not tags.

echo "2+2" | java -jar boxlang-1.0.0-all.jar
echo "2+2" | boxlang


# on *nix
cat test.cfs | java -jar boxlang-1.0.0-all.jar
cat test.cfs | boxlang

# on Windows
type test.cfs | java -jar boxlang-1.0.0-all.jar
type test.cfs | boxlang.bat

Other Command Line Arguments

We also support the following command line args right now.

  • -c "code here"—This is used to pass ad-hoc code to execute. Provide code in the next argument, quoted.

  • --config or -config - Pass a path to a JSON file for BoxLang configuration. See Runtime Configuration for more information.

  • --debug or -d - Enable debug mode (more debug logs!)

  • --home or -h - Pass a path to a custom runtime home directory for storing modules, configuration, and more. See Runtime Home Directory for more information.

  • --printAST or -p - Prints out BoxLang AST in JSON format for code provided via the -c flag (for debugging)

  • --transpile or -t - Prints out transpiled Java source that would be compiled to create the bytecode for the passed template path. (for debugging)

  • --version or -v - Output the current runtime's version information

  • path - The template, class, or script to execute

  • module:{name} - The executable module to execute. This will execute a Modules' ModuleConfig.main() method.

Using 3rd Party Jars

You can load custom third-party JARs at runtime by adding all your *.jar to the BOXLANG_HOME/lib folder. This will be loaded at runtime and available to use and integrate.

Environment Variables

The boxlang binary will also scan for several environment variables as overrides to the execution process.

Env VariablePurpose


Override the boxlang.json


Enable or disable debug mode


Override the HOME directory


Print the AST


Tranpile the code

At this point, you are done getting running with BoxLang. It's now your turn to write some code and get it running.

Last updated


Copyright & Register Trademark by Ortus Solutions, Corp & Ortus Software, LLC