183 } catch (IOException ex) {
184 Log.info(ex.toString());
185 Log.verbose(ex);
186 return null;
187 } catch (Exception ex) {
188 Log.info("Exception: "+ex);
189 Log.debug(ex);
190 return null;
191 }
192 }
193
194 private static final String RUNTIME_AUTO_DETECT = ".runtime.autodetect";
195
196 public static void extractFlagsFromRuntime(Map<String, ? super Object> params) {
197 if (params.containsKey(".runtime.autodetect")) return;
198
199 params.put(RUNTIME_AUTO_DETECT, "attempted");
200
201 String commandline;
202 File runtimePath = JLinkBundlerHelper.getJDKHome(params).toFile();
203 File launcherPath = new File(runtimePath, "bin\\java");
204
205 ProcessBuilder pb = new ProcessBuilder(launcherPath.getAbsolutePath(), "-version");
206 try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
207 try (PrintStream pout = new PrintStream(baos)) {
208 IOUtils.exec(pb, Log.isDebug(), true, pout);
209 }
210
211 commandline = baos.toString();
212 } catch (IOException e) {
213 e.printStackTrace();
214 params.put(RUNTIME_AUTO_DETECT, "failed");
215 return;
216 }
217
218 AbstractImageBundler.extractFlagsFromVersion(params, commandline);
219 params.put(RUNTIME_AUTO_DETECT, "succeeded");
220 }
221
222 @Override
223 public String getName() {
|
183 } catch (IOException ex) {
184 Log.info(ex.toString());
185 Log.verbose(ex);
186 return null;
187 } catch (Exception ex) {
188 Log.info("Exception: "+ex);
189 Log.debug(ex);
190 return null;
191 }
192 }
193
194 private static final String RUNTIME_AUTO_DETECT = ".runtime.autodetect";
195
196 public static void extractFlagsFromRuntime(Map<String, ? super Object> params) {
197 if (params.containsKey(".runtime.autodetect")) return;
198
199 params.put(RUNTIME_AUTO_DETECT, "attempted");
200
201 String commandline;
202 File runtimePath = JLinkBundlerHelper.getJDKHome(params).toFile();
203 File launcherPath = new File(runtimePath, "bin\\java.exe");
204
205 ProcessBuilder pb = new ProcessBuilder(launcherPath.getAbsolutePath(), "-version");
206 try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
207 try (PrintStream pout = new PrintStream(baos)) {
208 IOUtils.exec(pb, Log.isDebug(), true, pout);
209 }
210
211 commandline = baos.toString();
212 } catch (IOException e) {
213 e.printStackTrace();
214 params.put(RUNTIME_AUTO_DETECT, "failed");
215 return;
216 }
217
218 AbstractImageBundler.extractFlagsFromVersion(params, commandline);
219 params.put(RUNTIME_AUTO_DETECT, "succeeded");
220 }
221
222 @Override
223 public String getName() {
|