Hello World
This guide assumes you already installed Klar via Loom.
Create a project (optional)
loom new exists mainly to generate a simple project tree and README.
It is not required to run Klar.
loom new my-project
cd my-project
Loom will generate something like:
.
├── out/
├── README.md
└── src/
└── main.kl
Your first Klar program
Create src/main.kl:
@Use("java")
public void main(){
println("Hello from Klar!");
return null;
}
Notes:
@Use("java")is requiredpublicis requiredvoidfunctions still return explicitly (return;also works, butreturn null;is currently recommended)
Run it
kc run src/main.kl
Expected output:
Hello from Klar!
Program exited with code: 0
Where output goes
Klar generates Java output in:
out/
You will usually see both:
*.java*.class
If you get an error
Klar fails fast and prints a structured diagnostic. Start with:
- the diagnostic code (
[K:Exxx]) - the category (LEXICAL, SYNTAX, SEMANTIC, BACKEND, CLI)
- the fix section
Further on, the Diagnostic Docs explain this in more detail.