JEnv-for-Windows icon indicating copy to clipboard operation
JEnv-for-Windows copied to clipboard

Option to download and install java versions

Open rcsilva83 opened this issue 3 years ago • 8 comments

Would be super convenient if jenv could not only switch Java versions, but also had the ability to go ahead and install the configured version. It's also desirable the ability do configure a "dist URL" to be able to download from a local mirror when the user is behind a corporate firewall.

rcsilva83 avatar Aug 17 '22 12:08 rcsilva83

Im not sure if this should really be a jenv feature. If this feature would be implemented the only thing it would do is downloading the installer from the java website and running the exe. This would save the user 1 google query and 3 clicks. However by manipulating the jenv script or hosts.txt security vulnerabilities could be introduced easily. It might even trigger some anti virus applications when an application downloads code from the internet and executes it.

What I could imagine is that jenv automatically opens the website of the desired version.

But what do you think? You may still convince me of this feature

FelixSelter avatar Aug 17 '22 17:08 FelixSelter

This is a feature provided by SDKman and it seems to work fine.

I think you can see the real benefit from this feature when you think on a scale of hundreds of developers on an organization. Better yet, if we had a .jenv file with the JDK version on the project, it would be possible to git clone and type some kind of jenv config command that would download and set the JDK for it.

rcsilva83 avatar Aug 18 '22 14:08 rcsilva83

Yea I start liking the idea. This can easily be integrated with #36 See my comment on the linked pull request for further details.

The only question remaining is how to find out where the user installed the java version. May #32 can be implemented efficiently.

I also remember that you could pass a command line argument to the java installer to run silently in the background and install to a specific location. But I doubt it would be a good idea to take that much control from the user. What if he wants to but it at another drive?

Further investigation is needed

FelixSelter avatar Aug 18 '22 14:08 FelixSelter

Not sure if this helps, but Disco API may provide an interface with a catalog of available openjdk distributions.

ebresie avatar Aug 21 '22 15:08 ebresie

Wow thank you. That makes it a lot easier. Will need to see if they work with silent installation. But in theory I only have to call https://api.foojay.io/disco/v3.0/packages?version=<version>&operating_system=windows&directly_downloadable=true&archive_type=msi now

FelixSelter avatar Aug 21 '22 17:08 FelixSelter

To retrieve the architecture for disco api we could use the following:

$architecture = Get-CimInstance -ClassName Win32_Processor | Select-Object -ExpandProperty Architecture

$architecture can then be the following:

x86 (0) MIPS (1) Alpha (2) PowerPC (3) ARM (5) ia64 (6) x64 (9) ARM64 (12)

[System.Environment]::Is64BitOperatingSystem

FelixSelter avatar Aug 31 '22 20:08 FelixSelter

@rcsilva83 Would your distro url look something like this: ``https://example.com/%version%/download/installer.msi`
If not could you provide an example?

FelixSelter avatar Aug 31 '22 20:08 FelixSelter

Similiar tools like 'pyenv' and 'nvm' also list of available versions and do the actual download of the tools. It would be great if jenv could do the same.

dibog avatar Feb 22 '23 18:02 dibog