Compiling to a standalone application

A Java application is a Java class with a special method (whose name is main). The application can be invoked directly by naming it in the Java command. If you want to generate an application from a Scheme program, create a Scheme source file with the definitions you need, plus the top-level actions that you want the application to execute. You can compile in the regular way decribed in the previous section, but add the --main option. For example, assuming your Scheme file is MyProgram.scm:

kawa --main -C MyProgram.scm

This will create a MyProgram.class which you can either load (as decribed in the previous section), or invoke as an application:

java MyProgram [args]

Your Scheme program can access the command-line arguments args by using the global variable ‘command-line-arguments’.