Skip to content

Your First Project

m0rkeulv edited this page Oct 25, 2026 · 7 revisions

This page shows how to create a new Haxe project or open an existing one, what the plugin sets up for you, and how to build and run your first program. It assumes you have installed the plugin and registered a Haxe SDK; if not, start with Installation.

Create a new project

Open the New Project dialog: click New Project on the Welcome screen, or choose File | New | Project. The plugin adds two entries to it:

Entry Where in the dialog What it creates
Haxe In the list of languages on the left A module with a src folder. With Add sample code selected, also src/Main.hx and a build.hxml that runs Main in the Haxe interpreter.
Haxe Template Under Generators on the left A project from a template: Empty, HXML, Lime, OpenFL, NME or Haxelib. The templates ask for the settings their build files need.

Both entries have a Haxe SDK: field. Pick a registered Haxe SDK, or add one from the field's drop-down list. The SDK you pick becomes the project default.

The New Project dialog with the Haxe and Haxe Template entries

The Haxe and Haxe Template entries in the New Project dialog

Available templates

The Haxe Template entry offers these templates:

Template Fields Files it creates
Empty none A module with a src folder
HXML Target:, Main class:, Dead code elimination:, Output:; Generate source map for JavaScript; Stage:, FPS:, Background: and SWF version: for Flash src/<Main class>.hx and build.hxml
Lime, OpenFL Target:, Application name:, Package:, Window size: and FPS: project.xml and src/Main.hx
NME the same as Lime project.nmml and src/Main.hx
Haxelib Library name:, License:, Version:, Description:, URL:, Tags:, Contributors: and Release note: haxelib.json, a starter class in src, and dev.hxml, a build file for IDE support (completion and diagnostics) that compiles the library with --interp
The targets the HXML template offers
  • HashLink (VM bytecode)
  • HashLink (HL/C sources)
  • JavaScript
  • Neko
  • C++ (hxcpp)
  • JVM (.jar)
  • Java (generated sources)
  • C# (generated sources)
  • PHP
  • Python
  • Lua
  • Flash
  • Eval (interpreter)
The targets the Lime and OpenFL templates offer by default
  • HTML5
  • Windows
  • Mac OS
  • Linux
  • HashLink
  • Neko
  • Raspberry Pi
  • Flash
  • Adobe AIR
  • Android
  • iOS
  • tvOS
  • WebAssembly
  • Electron
The targets the NME template offers by default
  • Desktop (C++)
  • Cppia
  • Android
  • Android (library view)
  • Android (simulator)
  • iOS
  • iOS (device debugging)
  • iOS (simulator)
  • iOS (library view)
  • watchOS
  • watchOS (simulator)
  • Flash
  • Windows
  • Windows Arm64
  • WinRT / UWP
  • Mac OS
  • Linux
  • Raspberry Pi
  • RG350 console
  • Neko
  • HTML5 (jsprime)

The Output: field follows the target you pick until you edit it; Eval (interpreter) writes no output, so it has no Output: field. For Lime, OpenFL and NME, the Target: list comes from Settings | Languages & Frameworks | Haxe | Frameworks; see Targets and Sections.

Every template also has a Haxelib repository: field:

  • Global: libraries come from your haxelib repository, as set up in Installation.
  • Local (.haxelib): creates a .haxelib folder in the project. haxelib then installs and finds libraries for this project in that folder. The folder is excluded from the module's sources.

The generated build file becomes the project's active build file and the module's Build command, so the project builds right away. For Lime, OpenFL and NME, the target you picked becomes the build file's selected target. Core Concepts explains these terms.

A Lime, OpenFL or NME project needs its framework library. If haxelib does not have it yet, the library shows in red in the Haxe tool window: right-click the build file's Libraries node and choose Install All Missing Libraries.

Tip

The files the templates create come from editable file templates. Change them under Settings | Editor | File and Code Templates, on the Other tab, in the Haxe project group.

The Other tab of File and Code Templates with the Haxe project group and the text of the Lime project template

The Haxe project group on the Other tab; select a template to edit its text on the right

Open an existing project

  1. Choose File | Open and select the folder that contains your build file, for example build.hxml or project.xml.
  2. IntelliJ IDEA asks whether you trust the project. See Trust the project.
  3. Open the Haxe tool window: View | Tool Windows | Haxe. By default it sits on the right side of the window.

Important

A project set up with version 1.x of the plugin needs a one-way conversion first. See Migrating from 1.x.

What the plugin detects

When the project opens, the plugin does this for you:

  • Build files. hxml files, Lime and OpenFL project files, NME .nmml files and .hxp files at the top level of the project folder and of each module's folder show up in the Haxe tool window. Files in subfolders are not picked up automatically, because tools such as OpenFL write generated build files there. To add one, right-click the Build files node and choose Add Build File…, or right-click the file in the Project view and choose Add as Haxe Build File. See Build Files.
  • Source folders. If a module has no source folders yet, the class paths of its build files become source folders, and the folders the builds write to are excluded. A module that already has source folders is left alone.
  • The build of each file. Each source file is analyzed with the build file that compiles it, and the status bar shows which one. See Resolve Context.
  • The active build file. If the project has exactly one build file, it becomes the active build file.
  • The SDK. Each module gets the SDK chosen for it, or the project default. See Choose the SDK.
  • Libraries. The haxelib libraries your build files use show up under External Libraries in the Project view. The plugin resolves them each time it opens a trusted project; an untrusted project waits until you trust it. See Libraries and Haxelib.

When you later edit a build file, a Sync Haxe Changes button appears in the top-right corner of the editor. Click it, or click Reload Haxe Project in the tool window's toolbar, to pick up the change.

The Sync Haxe Changes button in the editor's top-right corner, with its tooltip

The Sync Haxe Changes button after an edit to a project file

What you may need to set yourself

  • The SDK, in a project you open from disk that has no project default yet. See Choose the SDK.
  • The active build file, when several build files compile the same source folders. Right-click the build file in the tool window and choose Set as Active Build File.
  • The Build command, if Build | Build Project should build something other than the module's default build file, or nothing at all. Right-click an action under a build file, such as Build, and choose Set as Build Command. Or click the value of the Build command row under Compilation to configure it. See Building and Running.
  • Missing libraries. Libraries that are not installed show in red. Right-click the build file's Libraries node and choose Install All Missing Libraries.

Trust the project

A Haxe build runs code from the project itself: compiler macros, .hxp scripts and tools such as Lime from a project-local haxelib repository. IntelliJ IDEA asks whether you trust a project before it opens one from an unknown location. The dialog Trust and Open Project '…'? offers Trust Project, Preview in Safe Mode and Don't Open. In safe mode, the editor shows a banner with a Trust project… link, so you can trust the project later.

In safe mode, you can read and edit the code, and the plugin's own code analysis keeps working. The plugin starts nothing that would run project code:

  • Lime, OpenFL, NME and HXP build files are not evaluated. The tool window shows only what the file itself declares.
  • The compilation server does not start, so compiler-backed features such as compiler diagnostics are off. The Compilation server row in the tool window reads project not trusted — compiler evaluation disabled.
  • Builds and commands do not run. Build | Build Project, the Build command row and the tools in the Haxe tool window ask you to trust the project first. A compile step before a launch is skipped with Compile skipped: the project is not trusted.

The first time the plugin skips something, it shows the notification Haxe: Project Is Not Trusted with a Trust Project… link. When you trust the project, the plugin reloads it at once; you do not have to reopen it. JetBrains explains trust and safe mode in Project security.

Choose the SDK

Each module needs a Haxe SDK. If a module has none, Haxe files in it show the banner No Haxe SDK is configured for this module - pick one here or in the Haxe tool window under Environment. Click Setup SDK in the banner and pick one.

In the Haxe tool window, the SDK row under a module's IDE environment node shows the module's SDK:

  • Project default (Haxe 4.3.7), for example, means the module follows the project default set in Settings | Build, Execution, Deployment | Build Tools | Haxe.
  • Project default (none) means no project default is set yet. This happens in a project you opened from disk; the new-project wizard sets the default for you. Set one in Build Tools | Haxe, or click the value and pick an SDK for this module.

See Installation for registering SDKs and choosing them.

Build and run your first program

This walkthrough needs only Haxe. It creates a project that runs in the Haxe interpreter.

  1. Choose File | New | Project and select Haxe in the list on the left.

  2. Enter a Name:, for example hello, pick a Haxe SDK: and make sure Add sample code is selected.

  3. Click Create. The project contains:

    src/Main.hx:

    class Main {
        static function main() {
            trace("Hello, Haxe!");
        }
    }

    build.hxml:

    -cp src
    -main Main
    --interp
  4. Open the Haxe tool window (View | Tool Windows | Haxe).

  5. Expand Build files and then build.hxml. The file is marked (Active). Under it you see Target, Defines, IDE Overrides, Libraries and Actions.

  6. Expand Actions and double-click Build (it shows the command haxe build.hxml). If IntelliJ IDEA asks whether to trust the project, trust it.

  7. The Run tool window opens and shows the output of the program: a line ending in Hello, Haxe!.

The first run creates a run configuration named build.hxml Build, so you can run it again from the run configuration list in the main toolbar. Build | Build Project also works: it runs the module's Build command in a Haxe Build tab of the Run tool window.

For an interpreter build, Actions also has a Run row. Double-click it to run the program as a Haxe Interpreter configuration, or right-click it and choose Debug. See Debugging with the Interpreter.

The sample project in IntelliJ IDEA: Main.hx and build.hxml in the editor, the Haxe tool window and the program's output in the Run tool window

The sample project after a run, with its output in the Run tool window

Build a program and run its output

To run a compiled program, use a target with a runtime. This example uses HashLink, so you need the HashLink runtime; see Installation.

  1. Choose File | New | Project and select Haxe Template under Generators.

  2. Pick HXML as the Template: and HashLink (VM bytecode) as the Target:. Keep the Output: out/app.hl, and click Create. The generated build.hxml:

    -cp src
    -main Main
    -dce std
    --hl out/app.hl
  3. In the Haxe tool window, expand the build file's Actions. Besides Build, it lists Build & run with the value HashLink Application.

  4. Double-click Build & run. The plugin creates a run configuration named build.hxml (HashLink) that compiles the build file first and then runs out/app.hl. The output appears in the Run tool window.

  5. To debug, right-click Build & run and choose Debug. See Debugging HashLink.

You can start the same from the editor: src/Main.hx shows a run icon beside static function main(). Click it and choose Run 'build.hxml (HashLink)' or Debug 'build.hxml (HashLink)'.

Build & run appears for builds whose output the plugin knows how to launch, such as HashLink bytecode, JavaScript for a browser or Node.js, Neko and C++ executables. See Building and Running for every target, and Run Configurations for the configurations it creates.

Next steps

Clone this wiki locally