I’m on Haxe 4.0.5 yet, still waiting for 4.1.0 to arrive in Manjaro packages. And I’m experimenting with the JVM backend, I’m looking forward to use Haxe to glue together quite a few JVM libraries with my business logic written in Haxe, as I don’t generally like Java or Maven ecosystem or IntelliJ/Eclipse, but want to use those libraries. But anyway.
I was wondering why ‘–java-lib’ is not listed in the ‘–help’ of the compiler? I’ve had some hard time digging it up, so I could include some jars to Haxe project. Also the documentation on Java/JVM target is very lacking. “-D jvm” is kinda hard to find too.
Is it possible to add all jars in some specific folder, so I don’t have to add each jar manually to build.hxml? I’m having quite a few of them. For example I’m planning to use Apache Tika which is 118 jars and it will be a nightmare to add --java-lib for all of those manually.
Also I tried out calling Javalin library (which is a micro web framework) from Haxe, but after just importing it and referencing one class I got an error at compile time: “type not found java.util.function.consumer”. Why is it happening? Can I fix it somehow?
In Haxe 4.0.5 in “–help” in the “Target-specific” options we only have:
--swf-version <version> change the SWF version
--swf-header <header> define SWF header (width:height:fps:color)
--flash-strict more type strict flash API
--net-std <file> add a root std .NET DLL search path
--c-arg <arg> pass option <arg> to the native Java/C# compiler
Well, yes, having this feature would be nice. I think I can make a script to unpack all the jars in a folder and then pack all the class files to a single uber-jar. Also it seems that Haxe compiler is okey parsing a folder of class files, so technically I may just unpack the class files from the jars to a single folder. Don’t know if it will be fine, as jars also may contain metadata and resources, so I might break something this way. And I need a way to package all class files with my Haxe code to a single uber-jar. This stuff will need some testing.
So this is because ‘function’ is a keyword in Haxe, right? But I’m not actually using java.util.function.consumer in my code. It seems that it bugs out when the jar I’m referencing uses java.util.function.consumer or something.
These are some info I created on Java target on the old site, it my well be very out of date and I am not sure if I found all links below, when the new site was created I was not involved, and relevant ones have not been updated and transferred.
I think quite a bit of java and flash stuff has more documentation on the old site. I have read a lot on Java but I have only every coded any Java via Haxe which I guess is rather unusual, I think I was probably one of the first to really explore the Haxe Java target, as a way of learning some Java.
At the time I mostly explored Swing/AWT because -lib-java only worked on some Jars and these worked without jars, I believe it now works with JavaFX. Caue and others have improved Java target no end since the early days, pretty much all the ‘sys’ package should work with Haxe Java so any reading and writing files.
Basis is an interesting Haxe Java project that might be worth a look.
This is another Java haxe related project that’s interesting.
The other place to look for Haxe Java code is in the toolkits, they all connect with Java to provide android extensions, but often they are too complex to be really much use for understanding more around Haxe Java use.
Anyway hope something in the links I posted is useful, although I expect you found these already. I have not tried JVM target yet.
The Haxe manual was written by Simn above, now the main complier writer, it is very technical orientated so it’s ideal for providing a language specification and is an amazing piece of work, but as numerous people have pointed out it’s not always suitable to learn Haxe if you don’t already mostly know Haxe unless perhaps your a compiler writer, So you won’t be the first to complain you could not find details, they are normally in there somewhere, a reasonably simple language but with the various ecosystems becomes complex.
Often the old manual has more verbose entries that are more useful for some aspects, Simn was never a fan of the first manual, it was a mess and not as technically accurate - he never quite understood that not everyone has his mind and I am sure I am not the only one that normally checks both, mainly because others have told my they do as well. For most users the haxe cookbook is often the ideal place to explore and then chat on the haxe discord.
While I am sure JVM is wonderful there is no reason not to explore the Java target, I do not think it will be removed anytime soon it’s now fairly mature, I think he just hates maintaining less interesting languages he’s determined to remove flash! Hopefully the width of users moderates his passion for perfection with the pragmatism that we all end up having to code some PHP or something horrible at one time or another and that’s when it’s great Haxe can help.
Well Java Swing has always seemed pretty stable to me with Haxe.
My JigsawX still works on Mojave, I think it was originally created on Leopard or Tiger so with Haxe a long time ago.
just download the jar and tablecloth.jpg
from terminal just run ( make sure image is next to it ).
java -jar JigsawxJava.jar
I have not tried building it recently but have updated over the years once or twice, I think it may have an attempt at using threads, I have not done any threads on any other haxe target yet.
Then I am pretty sure the hxDaedalus Swing example works well, created with Azrafe7.
I presume these still work with the current compiler ?
I guess since Caue does not get much time to contribute the Java and C# targets get neglected compared to some, but when Franco was too busy that happened with PHP but then it was later rebuilt. Seems a lot of negativity to Java target, for terminal stuff it’s always worked extremely reliably without giving me problems, I guess your talking about integrating with large Java ecosystems, well that’s never completely simple due to amount of tooling and workflows they often have, the only target haxe blends seamlessly with was the flash target, for instance I use haxe js all the time but you can’t just dump some haxe js in angular2 without tweaking it.
Maybe there are some compiler details for the Java target but if you just want to create something in Java swing/awt or slick2d then it’s fine.