6
I am creating an IDE and when the user presses to run the code I do the following:
try {
File file = new File(arquivoSelecionado.nome);
try {
FileWriter fw = new FileWriter(file);
fw.append(code.getText());
fw.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
Runtime.getRuntime().exec("C:\\Program Files\\Java\\jdk1.8.0_31\\bin\\javac "+file.getName());
Thread.sleep(2000);
Process pro = Runtime.getRuntime().exec("cmd /c start java "+file.getName().replaceAll(".java", ""));
} catch (Exception e1) {
e1.printStackTrace();
}
only that as it is possible to see I am putting a fixed path to the jdk folder, in this case the version is the one that is in my computer, the problem is that when the jdk version is different from the one that is in the fixed path it does not run the terminal running the program
what I wanted to know is if there is any way to identify the version of jdk that the IDE is running on
The ideal would be to check the java environment variable and so know the JDK installation path
– Viktor Hugo
%JAVA_HOME% bin java if JAVA_HOME variable exists
– res