You can declare existant haxe classes using the @JTranscNativeClass annotation and marking methods as native.
An example could be:
Or:
Take into account that some types are converted when called this way.
Primitive types: integral types will be converted to Int, but long that will be converted to haxe.Int64, and float and double will be converted to haxe Float.
byte[] will be converted into haxe.io.Bytes
java.lang.String will be converted into haxe.String.
java.io.InputStream will be converted into haxe.io.Input. When returning, it will do the opposite.
Other classes marked with @JTranscNativeClass will work directly without conversions.
This approach just works when targeting Haxe, so plase before using it, ensure you are using JTransc. Calling JTranscSystem.isJTransc() for example or with different mains injecting dependencies.
You can include haxelib libraries with the @HaxeAddLibraries annotation, and use MiniTemplates to reference java methods from Haxe code.