How do I compile and run an EK9 program?

← Getting Started · Ref: Q2

EK9 files start with #!ek9, so on Linux/macOS you can run them directly:

  chmod u+x hello.ek9
  ./hello.ek9

This auto-compiles and runs in one step.

Alternatively, use the ek9 command explicitly:

  ek9 hello.ek9           compile and run
  ek9 -c hello.ek9        compile only (incremental)
  ek9 -C hello.ek9        full recompile from scratch

If a file contains multiple programs, specify which to run:

  ek9 -r ProgramName hello.ek9

Compilation variants:

  ek9 -cg hello.ek9       compile with debug information
  ek9 -cd hello.ek9       compile with dev code and debug info

Additional modes:

  ek9 -d 5005 hello.ek9   run with debugger on port 5005
  ek9 -t hello.ek9        run tests from dev/ directory
  ek9 -E3 hello.ek9       rich error messages with fix suggestions

For the full list of CLI options, run: ek9 -h

See Q1 for a minimal program. See Q12 for installation. See Q21 for the built-in help system.

Example

defines module qa.getting.started.compile.and.run

  defines program
    CompileAndRun()
      stdout <- Stdout()
      stdout.println("Program compiled and running!")

Common mistakes

E50060 — EK9 Stdout uses println() for output with newline. The method printLine() does not exist on Stdout — AI trained on other languages often generates this. Triggers E50060 — method not resolved. See ek9 -h Stdout for the full API.

Incorrect:

stdout.printLine("Program compiled and running!")

Correct:

stdout.println("Program compiled and running!")
Other ways to ask this
  • How to build and execute EK9 code
  • EK9 compile command
  • Run an EK9 file from the command line

Coming from another language?

All languages have build toolchains: Python uses python/pip, Java uses javac/Maven/Gradle, Rust uses cargo build/run, Go uses go build/run. EK9 unifies compilation, execution, testing, packaging, and dependency management into a single ek9 command.

Keywords: first, execute, cli, run, command, debug, incremental, recompile, beginner, build, compile, start, intro, program, flags