Lets look at how to build and run a Fantom application. Given a basic Fantom project:

 |-- fan/
 |    `-- KickAss.fan
 `-- build.fan

We'll make KickAss.fan a simple Hello World program:

class KickAss {
    Void main() {
        echo("Fantom. Kick Ass!")

To compile this into a pod, we'll use this basic build.fan:

class Build : build::BuildPod {
    new make() {
        podName = "example"
        srcDirs = [`fan/`]
        depends = ["sys 1.0"]

This should build example.pod.

Building a Fantom Application

To build your application, run build.fan as a script:

C:\example>fan build.fan

compile [example]
  Compile [example]
    FindSourceFiles [1 files]
    WritePod [file:/C:/Apps/fantom-1.0.65/lib/fan/example.pod]

Pods are automatically saved into %FAN_HOME%\lib\fan along with all the other Fantom system pods. So example.pod is now part of the Fantom install!

Running a Fantom Application

We run applications in a similar way we run fantom scripts, only we prefix the class with the name of the pod:

C:\example> fan example::KickAss
Fantom. Kick Ass

Note the pod::class notation. See the docs for fan.exe for more details.

Note also that, unlike Java, we didn't have to specify a classpath or similar. Everything is taken from the Fantom install, even our example.pod. This simplifies execution quite a bit.

Let's make it even easier to launch our application, lets make a Main.fan in the fan/ directory:

class Main{
    Void main() {
        echo("My main() man.")

Now we can run our app by just specifying the pod:

C:\example> fan build.fan

C:\example> fan example
My main() man.
Fantom. Wotever

Note how if no class is specified, Fantom looks for one called Main. Also, if no method is specified, Fantom looks for one called main. If the method is an instance method, Fantom creates an instance via a no-args constructor.

Example, to call the main method directly we could type:

C:\example> fan example::KickAss.main

Again, see fan.exe documentation for more.