Search code examples
pythonjava-11

How to get the available jdk versions in install-jdk library of python?


I want to get all the jdk versions that available/supported for the time. I know the install-jdk library, but I think there's no function to get them, or I didn't notice. Do you know a way to get the jdk versions that the install-jdk can install?

import jdk

# like the example:
jdk.install("11")

but I want something like this:

versions = jdk.get_available_versions()
print(versions)

But there's not such a function I think..


Solution

  • The short answer is that you can't.

    If you look at the code, you will see that the Client classes actually don't know what the available versions are. Rather, they all1 just assemble a URL for the downloadable using whatever the caller provided as the version string, and then just attempt to connect to that URL.

    Given that web servers are not file systems, there is probably not a simple way (i.e. without gnarly webpage scraping) to query the download sites to find all available versions. (But ... hey ... there's nothing stopping you from trying.)


    1 - ... at the time of writing