microsoft / java-wdb

Windows Developer Box for Java Developers
MIT License
75 stars 1 forks source link

Better GraalVM native image geration support #5

Open Simulacron-3 opened 3 years ago

Simulacron-3 commented 3 years ago

Summary

Right now is very difficult to use the native-image tool on windows systems(you need to manually install Microsoft Visual C++ (MSVC) and it is difficult to find the right version based on jdk level and windows version). In addition to this on Windows the native-image tool only works when it is executed from the x64 Native Tools Command Prompt.

Basic example

As a Basic example you can think of any java project that has all the graalVM native image prerequisites(there are also several micro-framework that have graalVM support out of the box: micronaut, quarkus and even spring in the last versions is moving towards graalVM support).

Motivation

this feature will allow developers to build native executable for windows system, starting from java project built with graalVM(the first examples that comes to my mind are cli applications or even graphical applications and microservices). Native image generated applications are really interesting if you think about the cloud landscape and it's requirements.

Thanks

brunoborges commented 3 years ago

Thanks @Simulacron-3 for the great suggestion. Could you please also share the link to the GraalVM documentation that suggests MSVC is required, and how to build native images on Windows?

Simulacron-3 commented 3 years ago

Sure, you can find all information in this page

https://www.graalvm.org/docs/getting-started-with-graalvm/windows/

you can build native images using the native-image tool (downloadable with the gu utility offered by graalVM: gu install native-image ) with something like this:

native-image [options] -jar jarfile [imagename] [options]

brunoborges commented 3 years ago

Also reported on Reddit: https://www.reddit.com/r/java/comments/jxllez/java_development_on_windows_request_for/gcxf3l3/

gdoenlen commented 3 years ago

I'd also look at the Quarkus docs for building native executables (ctrl + f for windows) there's good info there.

The main problem in my opinion isn't installing MSVC BuildTools (thats just a fact of life on Windows with C/C++ development), but rather having to start the x64 Native Tools Command Prompt to build every time. It doesn't work with the modern flow of windows terminal, powershell, and just calling mvn package -P native.

Simulacron-3 commented 3 years ago

I am aware of that guide but you have to consider that not every java programmer is also a C/C++ programmer :) I think that if there will be a simple/standard process is better for everyone.