Running the First Cangjie Program

With everything in place, let's compile and run the first Cangjie program!

First, create a text file named hello.cj in an appropriate directory and enter the following Cangjie code into the file:

// hello.cj
main() {
    println ("Hello, Cangjie")
}

This code uses the Cangjie comment syntax. You can write a single line of comments after // or multiple lines of comments between /* and */ . The syntax is the same as that of other languages such as C and C++. The contents of the comments do not affect program compilation and running.

Then, run the following command in the directory:

cjc hello.cj -o hello

The Cangjie compiler compiles the source code in hello.cj to an executable file hello on the platform. Run the file in the CLI. The following program output is displayed:

Hello, Cangjie

Note:

The preceding compilation command applies to Linux. If you use Windows, change the compilation command to cjc hello.cj -o hello.exe.