runtime — minecraft-launcher-lib 8.0 documentation

# runtime

runtime allows to install the java runtime. This module is used by `install_minecraft_version()`, so you don’t need to use it in your code most of the time.

get_jvm_runtimes() → list[str]

  Returns a list of all jvm runtimes

  Example:

      for runtime in minecraft_launcher_lib.runtime.get_jvm_runtimes():
          print(runtime)

  Return type:

    list[str]

get_installed_jvm_runtimes(minecraft_directory: str | PathLike) → list[str]

  Returns a list of all installed jvm runtimes

  Example:

      for runtime in minecraft_launcher_lib.runtime.get_installed_jvm_runtimes():
          print(runtime)

  Parameters:

    minecraft_directory (str | PathLike) – The path to your Minecraft directory

  Return type:

    list[str]

install_jvm_runtime(jvm_version: str, minecraft_directory: str | PathLike, callback: CallbackDict | None = None, max_workers: int | None = None) → None

  Installs the given jvm runtime. callback is the same dict as in the install module.

  Example:

      runtime_version = "java-runtime-gamma"
      minecraft_directory = minecraft_launcher_lib.utils.get_minecraft_directory()
      minecraft_launcher_lib.runtime.install_jvm_runtime(runtime_version, minecraft_directory)

  Parameters:

    - jvm_version (str) – The Name of the JVM version

    - minecraft_directory (str | PathLike) – The path to your Minecraft directory

    - callback (CallbackDict | None) – the same dict as for `install_minecraft_version()`

    - max_workers (int | None) – number of workers for asynchronous downloads. If None, max_workers will be set automatically.

  Raises:

    - VersionNotFound – The given JVM Version was not found

    - FileOutsideMinecraftDirectory – A File should be placed outside the given Minecraft directory

  Return type:

    None

get_executable_path(jvm_version: str, minecraft_directory: str | PathLike) → str | None

  Returns the path to the executable. Returns None if none is found.

  Example:

      runtime_version = "java-runtime-gamma"
      minecraft_directory = minecraft_launcher_lib.utils.get_minecraft_directory()
      executable_path = minecraft_launcher_lib.runtime.get_executable_path(runtime_version, minecraft_directory)
      if executable_path is not None:
          print(f"Executable path: {executable_path}")
      else:
          print("The executable path was not found")

  Parameters:

    - jvm_version (str) – The Name of the JVM version

    - minecraft_directory (str | PathLike) – The path to your Minecraft directory

  Return type:

    str | None

get_jvm_runtime_information(jvm_version: str) → JvmRuntimeInformation

  Returns some Information about a JVM Version

  Example:

      runtime_version = "java-runtime-gamma"
      information = minecraft_launcher_lib.runtime.get_jvm_runtime_information(runtime_version)
      print("Java version: " + information["name"])
      print("Release date: " + information["released"].isoformat())

  Parameters:

    jvm_version (str) – A JVM Version

  Raises:

    - VersionNotFound – The given JVM Version was not found

    - VersionNotFound – The given JVM Version is not available on this Platform

  Returns:

    A Dict with Information

  Return type:

    JvmRuntimeInformation

get_version_runtime_information(version: str, minecraft_directory: str | PathLike) → VersionRuntimeInformation | None

  Returns information about the runtime used by a version

  Example:

      minecraft_version = "1.20"
      minecraft_directory = minecraft_launcher_lib.utils.get_minecraft_directory()
      information = minecraft_launcher_lib.runtime.get_version_runtime_information(minecraft_version, minecraft_directory)
      print("Name: " + information["name"])
      print("Java version: " + str(information["javaMajorVersion"]))

  Parameters:

    - minecraft_directory (str | PathLike) – The path to your Minecraft directory

    - version (str)

  Raises:

    VersionNotFound – The Minecraft version was not found

  Returns:

    A Dict with Information. None if the version has no runtime information.

  Return type:

    VersionRuntimeInformation | None

View the source code of this module