@Test void testExtractionOfRuntime() { final String javaHome = JavaSystemProperties.getJavaHome(); final Path home = FileSystems.getDefault().getPath(javaHome); final JavaRuntimeProperties result = JavaRuntimePropertiesDetector.getProperties(home); assertNotNull(result); assertEquals(JavaSystemProperties.getJavaVendor(), result.getVendor()); assertEquals(JavaSystemProperties.getJavaVersion(), result.getVersion()); assertEquals(JavaSystemProperties.getOsName(), result.getOsName()); assertEquals(JavaSystemProperties.getOsArch(), result.getOsArch()); }
public static JavaRuntimeProperties getProperties(Path javaHome) throws IllegalStateException { LOG.info("Trying to get definition of local JVM at '{}'", javaHome); final String java = JavaExecutableFinder.findJavaExecutable(javaHome); try { final ProcessBuilder processBuilder = new ProcessBuilder(java, SHOW_SETTINGS_ARG, VERSION_ARG); final ProcessResult processResult = ProcessUtil.runProcess(processBuilder, 5, TimeUnit.SECONDS); if (processResult.wasUnsuccessful()) { LOG.debug("The java process printed the following content to 'error out': {}", processResult.getErrorOut()); throw new RuntimeException("Failed to execute java binary"); } return extractProperties(processResult.getStandardOut(), processResult.getErrorOut()); } catch (final Exception ex) { final String message = String.format("Can not get properties for JVM in path '%s'.", java); LOG.error(message, ex); throw new IllegalStateException(message, ex); } }
JavaRuntimePropertiesDetector { public static JavaRuntimeProperties getProperties(Path javaHome) throws IllegalStateException { LOG.info("Trying to get definition of local JVM at '{}'", javaHome); final String java = JavaExecutableFinder.findJavaExecutable(javaHome); try { final ProcessBuilder processBuilder = new ProcessBuilder(java, SHOW_SETTINGS_ARG, VERSION_ARG); final ProcessResult processResult = ProcessUtil.runProcess(processBuilder, 5, TimeUnit.SECONDS); if (processResult.wasUnsuccessful()) { LOG.debug("The java process printed the following content to 'error out': {}", processResult.getErrorOut()); throw new RuntimeException("Failed to execute java binary"); } return extractProperties(processResult.getStandardOut(), processResult.getErrorOut()); } catch (final Exception ex) { final String message = String.format("Can not get properties for JVM in path '%s'.", java); LOG.error(message, ex); throw new IllegalStateException(message, ex); } } }
JavaRuntimePropertiesDetector { public static JavaRuntimeProperties getProperties(Path javaHome) throws IllegalStateException { LOG.info("Trying to get definition of local JVM at '{}'", javaHome); final String java = JavaExecutableFinder.findJavaExecutable(javaHome); try { final ProcessBuilder processBuilder = new ProcessBuilder(java, SHOW_SETTINGS_ARG, VERSION_ARG); final ProcessResult processResult = ProcessUtil.runProcess(processBuilder, 5, TimeUnit.SECONDS); if (processResult.wasUnsuccessful()) { LOG.debug("The java process printed the following content to 'error out': {}", processResult.getErrorOut()); throw new RuntimeException("Failed to execute java binary"); } return extractProperties(processResult.getStandardOut(), processResult.getErrorOut()); } catch (final Exception ex) { final String message = String.format("Can not get properties for JVM in path '%s'.", java); LOG.error(message, ex); throw new IllegalStateException(message, ex); } }  }
JavaRuntimePropertiesDetector { public static JavaRuntimeProperties getProperties(Path javaHome) throws IllegalStateException { LOG.info("Trying to get definition of local JVM at '{}'", javaHome); final String java = JavaExecutableFinder.findJavaExecutable(javaHome); try { final ProcessBuilder processBuilder = new ProcessBuilder(java, SHOW_SETTINGS_ARG, VERSION_ARG); final ProcessResult processResult = ProcessUtil.runProcess(processBuilder, 5, TimeUnit.SECONDS); if (processResult.wasUnsuccessful()) { LOG.debug("The java process printed the following content to 'error out': {}", processResult.getErrorOut()); throw new RuntimeException("Failed to execute java binary"); } return extractProperties(processResult.getStandardOut(), processResult.getErrorOut()); } catch (final Exception ex) { final String message = String.format("Can not get properties for JVM in path '%s'.", java); LOG.error(message, ex); throw new IllegalStateException(message, ex); } }  static JavaRuntimeProperties getProperties(Path javaHome); }
JavaRuntimePropertiesDetector { public static JavaRuntimeProperties getProperties(Path javaHome) throws IllegalStateException { LOG.info("Trying to get definition of local JVM at '{}'", javaHome); final String java = JavaExecutableFinder.findJavaExecutable(javaHome); try { final ProcessBuilder processBuilder = new ProcessBuilder(java, SHOW_SETTINGS_ARG, VERSION_ARG); final ProcessResult processResult = ProcessUtil.runProcess(processBuilder, 5, TimeUnit.SECONDS); if (processResult.wasUnsuccessful()) { LOG.debug("The java process printed the following content to 'error out': {}", processResult.getErrorOut()); throw new RuntimeException("Failed to execute java binary"); } return extractProperties(processResult.getStandardOut(), processResult.getErrorOut()); } catch (final Exception ex) { final String message = String.format("Can not get properties for JVM in path '%s'.", java); LOG.error(message, ex); throw new IllegalStateException(message, ex); } }  static JavaRuntimeProperties getProperties(Path javaHome);  }