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();
}
As you can see I'm putting a fixed path to the jdk folder, in this case the version is the one found on my computer, the problem is that when the jdk version is different from the one on the path fixed it does not run the terminal by running the program
What I wanted to know is if you have any way to identify the version of jdk where the IDE is running