MCPcopy Create free account
hub / github.com/apache/fory / get_jdk_major_version

Function get_jdk_major_version

ci/tasks/java.py:25–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23
24
25def get_jdk_major_version():
26 try:
27 # Run the 'java -version' command
28 result = subprocess.run(["java", "-version"], capture_output=True, text=True)
29 output = result.stderr # java -version outputs to stderr
30
31 # Use regex to find the version string
32 match = re.search(r'version "([^"]+)"', output)
33 if not match:
34 return None
35
36 version_string = match.group(1)
37
38 # Parse the version string
39 version_parts = version_string.split(".")
40 if version_parts[0] == "1":
41 # Java 8 or earlier
42 return int(version_parts[1])
43 else:
44 # Java 9 or later
45 return int(version_parts[0])
46
47 except Exception:
48 return None
49
50
51# JDK versions

Callers 3

install_foryFunction · 0.85
run_graalvm_testFunction · 0.85
run_releaseFunction · 0.85

Calls 1

runMethod · 0.65

Tested by

no test coverage detected