HaxeFoundation / HaxeFoundation/haxe
[jvm] An unexpected error occurred while trying to open file Main.jar
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Hello.
This code compiles well to the JVM target, but the final .jar file executes with an error.
```haxe
package;
import haxe.Json;
import io.javalin.http.Context;
import io.javalin.http.Handler;
import io.javalin.Javalin;
final class Main implements Handler {
static function main() new Main();
function new() {
final app = Javalin.create().start(7000);
app.get("/", this);
}
public function handle(ctx:Context):Void {
ctx.result(Json.stringify({
status: "hello world!"
}));
}
}
```
Executing it as ` java -jar Main.jar` produces:
`Error: An unexpected error occurred while trying to open file Main.jar`
But the same code works well for the old Java target.
To reproduce it, you can download a sample: https://github.com/dmitryhryppa/javalin-haxe-helloworld
Then run: `haxe --run Install.hx`, it will download dependencies.
And then build `build.hxml` with the JVM target.
Thank you.
Contributor guide
Assessment
This issue has not been assessed yet.