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.
For example, assuming your Scheme file is
MyProgram.scm, you have two ways at your disposal to
compile this Scheme program to a standalone application:
kawa --main -C MyProgram.scm
--main option will compile all Scheme programs
received in arguments to standalone applications.
main: #tmodule compile option to your module.
;; MyProgram.scm (module-name <myprogram>) (module-compile-options main: #t)
kawa -C MyProgram.scm
This way you can compile multiple Scheme programs at once, and still control which one(s) will compile to standalone application(s).
Both methods will create a
MyProgram.class which you can either
load (as described 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’, or the R6RS function ‘command-line’.
If there is no explicit
module-export in a module compiled
--main then no names are exported. (The default
otherwise is for all names to be exported.)