CLI Java Detection

This commit is contained in:
Konloch 2021-07-12 05:14:05 -07:00
parent 948ae90e50
commit f966f7b29f

View file

@ -38,6 +38,7 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
* @author Konloch * @author Konloch
* @since 7/11/2021 * @since 7/11/2021
*/ */
public class ExternalResources public class ExternalResources
{ {
private static final ExternalResources SINGLETON = new ExternalResources(); private static final ExternalResources SINGLETON = new ExternalResources();
@ -60,12 +61,16 @@ public class ExternalResources
try try
{ {
BytecodeViewer.sm.pauseBlocking(); BytecodeViewer.sm.pauseBlocking();
//TODO read the version output to verify it exists //read the version output to verify it exists
ProcessBuilder pb = new ProcessBuilder("java", "-version"); ProcessBuilder pb = new ProcessBuilder("java", "-version");
pb.start(); Process p = pb.start();
p.waitFor();
Configuration.java = "java"; //java is set if(readProcess(p).toLowerCase().contains("java version"))
return Configuration.java; {
Configuration.java = "java"; //java is set
return Configuration.java;
}
} }
catch (Exception e) { } //ignore catch (Exception e) { } //ignore
finally finally