Sunday, October 2, 2022

A JavaFX Fanboy forgets about his Parallels subscription - what happens next?

Recently, I was informed by a friendly message on my phone that the yearly subscription fee for Parallels - THE best way to run windows on your mac - was already sucked away from my bank account. 



I rarely use it, in fact I didn’t start it on my M1 Mac ever. 


Well, screw it! I recently brushed up LogoRRR's UI and was curious how the changes would look like on windows. 


As such I went to the Parallels website, and in no time I had setup their product fresh on my computer. First thing I was informed was that I could throw away my old Windows Image which I transferred from my old macbook. The architectures wouldn't match, I was out of luck.


Great. Well as said before I didn’t really miss it too much and decided to proceed. Install everything from scratch.  How to get a new Windows? Very conveniently, I just clicked “next”. 


There you go, in no time I had a brand new Windows for aarch64 running on my virtual PC! Thanks to my internet connection and I could solve my first world problems in no time here.


My quest continued. 


Only after having installed IntelliJ and a proper JDK on this virtual machine and after a clone of LogoRRR resided on my virtual HD I realised that there was no build for Windows and aarch64 for JavaFX base libraries available. 






I was already suspicious after not having a choice to download a JDKFx from Azul? I was seeing the wall approaching very fast. 


But being on fire I checked out the openjfx source code as well, and tried to compile it. 🤷🏼‍♂️ 


I followed OpenJFX's build instructions - For example I downloaded Visual Studio. Which is available for Windows aarch64 in an early preview. Of course I realised this only after being informed by the 'normal' Visual studio installer that this platform I'm running on was not supported. 


I smiled along the way, no way this would work - but I continued.


After installing cygwin as well I was sure jfx wouldn’t compile, since this was only a x86 version for it.


Anyway, I continued, and after ignoring all warnings and instructions on the openjfx wiki to install a certain gradle version I just went with the most current one.


Finally, I got to execute gradle with the default task ‘sdk’. 


It promptly aborted with a message ‘platform not supported’. 


There you have it!


Well, I just searched the whole jfx source for this message, found it and short circuited the if statement which aborted the build.





To my suprise this was the only thing which was necessary for a successful build! I got all the jars and modules!?? 


Well ... ok!


But! I need maven artefacts to fire up LogoRRR - how go get those? The official docs state there existed some publish tasks for maven, but I couldn’t find it.


Being on fire I searched the source code again, and I was lucky again! There exists a property to activate those publish tasks, and I bravely activated them.




Having no idea what I was doing, but needing javafx modules graphics, control, swing and base in my local maven repository, I went on. I even defined my own version number for openjfx.


Now I changed the version for JavaFX in my LogoRRR’s code, changed the openjfx version and the module path in the run configuration and gave it a go.


After a peculiar long compilation time, finally LogoRRR showed up. 🥳


LogoRRR Screenshot


Lessons learned

I’m not really sure that I got a clean aarch64 build for openjfx on windows, more likely a mixture of an emulation and aarch64 bits of the build. Otherwise this would have been too easy. 


At least LogoRRR started up and worked like it was supposed to do. Which it didn’t prior to my quest. The trigger here was the message 'javafx platform not supported' in IntelliJ. 


… The broader message is that open source can work for you in many ways, for everybody on his level.


Programming has to do with a certain attitude. Often one reads of ‘fearless refactoring’. What should I be afraid of? No laptop exploded so far (I know of) because somebody renamed a variable ...


I also realised that openjfx is just a project like any other project - you can download it, inspect it, tinker with it ... you could even contribute to it in some or the other way - for example like i did with the answer on stackoverflow - all contributions are valuable, even if it is not always technically correct or imperfect.



No comments:

Post a Comment