# ApplicationMain.hx

**URL:** https://community.haxe.org/t/applicationmain-hx/4586
**Category:** Haxe
**Created:** [March 29, 2025, 11:33am UTC](https://community.haxe.org/t/applicationmain-hx/4586 "2025-03-29T11:33:28Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![den256](https://avatars.discourse-cdn.com/v2/letter/d/35a633/32.png) [@den256](https://community.haxe.org/u/den256)
#### Post date: [March 29, 2025, 11:33am UTC](https://community.haxe.org/t/applicationmain-hx/4586/1 "2025-03-29T11:33:28Z")

</div>

What I want to achieve

I’m writing Haxe with VSCode.

It seems that even if you add the write attribute and change ApplicationMain.hx,  
it is designed so that the system will overwrite (restore) it.

So I’d like to ask for your advice.

If there is a setting that will prevent the system from automatically restoring ApplicationMain.hx even if it is edited,  
I would really appreciate your advice.

What I’ve tried

I edited it with chmod 666 ApplicationMain.hx (default location).

However, the system immediately corrects the edited contents,

if I move ApplicationMain.hx to a different folder,  
it becomes editable,  
but that is meaningless from a development perspective,  
so I want to be able to freely edit ApplicationMain.hx in the default location  
while organically connecting it to other sources.

I’m using VSCode1.97.0 on Ubuntu 24 LTS arm.

---

<div class="post-metadata">

### Author: ![ablum](https://community.haxe.org/user_avatar/community.haxe.org/ablum/32/415_2.png) [@ablum](https://community.haxe.org/u/ablum)
#### Post date: [March 29, 2025, 12:05pm UTC](https://community.haxe.org/t/applicationmain-hx/4586/2 "2025-03-29T12:05:35Z")

</div>

I think I am correct to assume you use lime / openfl / flixel frameworks. I also believe that `lime` command is what generates `ApplicationMain.hx` in your export / output folder. it will do so on every compile / build.  
I usually don’t do a lot of lime / openfl work, but I think anything in export / output folder has to be considered “readonly”, since lime will re-generate it’s contents with every compilation run.  
so whatever you need to do by editing `ApplicationMain.hx` you need to find a different solution, because most likely you are doing something wrong or at least not in the spirit of the frameworks you’re using.

e.g. there might be a template file from which `ApplicationMain.hx` is generated and you might be able to change that without editing or forking the entire framework, but that’s probably a question for openfl or flixel community people.

---

<div class="post-metadata">

### Author: ![den256](https://avatars.discourse-cdn.com/v2/letter/d/35a633/32.png) [@den256](https://community.haxe.org/u/den256)
#### Post date: [March 29, 2025, 12:17pm UTC](https://community.haxe.org/t/applicationmain-hx/4586/3 "2025-03-29T12:17:22Z")

</div>

Thank you for your response, ablum.

Here’s the translation:

“Your perspective was very helpful. It made me reconsider a lot of things as well.”

---

<div class="post-metadata">

### Author: ![Igazine](https://community.haxe.org/user_avatar/community.haxe.org/igazine/32/1745_2.png) [@Igazine](https://community.haxe.org/u/Igazine)
#### Post date: [March 29, 2025, 3:32pm UTC](https://community.haxe.org/t/applicationmain-hx/4586/4 "2025-03-29T15:32:59Z")

</div>

@ablum is correct.

You can find ApplicationMain.hx in `{haxelib}/lime/{version}/templates/haxe`. You can just duplicate that file in your own source code logic, ie. copy the file to `Templates\haxe\ApplicationMain.hx` in the root of your code, then add `<template path="Templates"/>` in your project.xml. After that you can freely edit it, the compiler will pick the custom one up instead of the global one.

---

<div class="post-metadata">

### Author: ![den256](https://avatars.discourse-cdn.com/v2/letter/d/35a633/32.png) [@den256](https://community.haxe.org/u/den256)
#### Post date: [March 29, 2025, 3:42pm UTC](https://community.haxe.org/t/applicationmain-hx/4586/5 "2025-03-29T15:42:54Z")

</div>

Sure! Here’s the English translation:

“@Igazine, thank you so much for providing such valuable information. Thanks to your specific and practical advice, I now have a much clearer path forward.”

Let me know if you’d like any adjustments!

---

<div class="post-metadata">

### Author: ![joshtynjala](https://community.haxe.org/user_avatar/community.haxe.org/joshtynjala/32/792_2.png) [@joshtynjala](https://community.haxe.org/u/joshtynjala)
#### Post date: [March 31, 2025, 3:37pm UTC](https://community.haxe.org/t/applicationmain-hx/4586/6 "2025-03-31T15:37:08Z")

</div>

Here is a sample project that I created to demonstrate how to use a custom ApplicationMain.hx template with OpenFL:

> **[GitHub - joshtynjala/openfl-custom-app-main-sample: A sample OpenFL project that customizes the...](https://github.com/joshtynjala/openfl-custom-app-main-sample)**
>
> A sample OpenFL project that customizes the haxe/ApplicationMain.hx template file

---

<div class="post-metadata">

### Author: ![den256](https://avatars.discourse-cdn.com/v2/letter/d/35a633/32.png) [@den256](https://community.haxe.org/u/den256)
#### Post date: [April 3, 2025, 9:52am UTC](https://community.haxe.org/t/applicationmain-hx/4586/7 "2025-04-03T09:52:27Z")

</div>

Thank you for your response, joshtynjala.

---

<div class="post-metadata">

### Author: ![den256](https://avatars.discourse-cdn.com/v2/letter/d/35a633/32.png) [@den256](https://community.haxe.org/u/den256)
#### Post date: [April 27, 2025, 8:59pm UTC](https://community.haxe.org/t/applicationmain-hx/4586/8 "2025-04-27T20:59:31Z")

</div>

It was a misunderstanding of my thinking, and the question was wrong from the start.  
@ablum is correct.
