To get started with Haxe/Java, create a new folder and save this class as Main.hx
.
/** Multi-line comments for documentation. **/ class Main { static public function main():Void { // Single line comment trace("Hello World"); } }
To compile Haxe to Java we need two obvious prerequisites installed:
Run the following from the command line:
haxe --java bin --main Main
Another possibility is to create and run (double-click) a file called compile.hxml
. In this example the hxml-file should be in the same directory as the example class.
--java bin --main Main
The compiler outputs in the given bin-folder, which contains the generated sources / .jar files which prints the traced message when you execute it.
To execute, run the following command:
java -jar bin/Main.jar