For completeness, let me mention that there are some places (on a Windows PC) to search for javaw.exe if it is not found in the path: (Still Reimeus recommendation should be your first attempt.)
1.
Java usually stores its location in the registry under the following key:
HKLM\Software\JavaSoft\Java Runtime Environement\<CurrentVersion>\JavaHome
2.
Newer versions of the JRE / JDK seem to also put a copy of javaw.exe in "C: \ Windows \ System32", so you might need to check as well (although there is a chance if it is, it will be found in the path also).
3.
Of course, there are "normal" installation locations:
- 'C: \ Program Files \ Java \ jre * \ bin'
- 'C: \ Program Files \ Java \ jdk * \ bin'
- 'C: \ Program Files (x86) \ Java \ jre * \ bin'
- 'C: \ Program Files (x86) \ Java \ jdk * \ bin'
[Please note that for older versions of Windows (XP, Vista (?)) This will only help on English versions of the OS. Fortunately, in a later version of Windows, "Program Files" will point to a directory regardless of its "display name" (which depends on the language).]
Some time ago, I wrote this piece of code to check javaw.exe in the above places. Maybe someone finds this useful:
static protected String findJavaw() { Path pathToJavaw = null; Path temp; /* Check in Registry: HKLM\Software\JavaSoft\Java Runtime Environement\<CurrentVersion>\JavaHome */ String keyNode = "HKLM\\Software\\JavaSoft\\Java Runtime Environment"; List<String> output = new ArrayList<>(); executeCommand(new String[] {"REG", "QUERY", "\"" + keyNode + "\"", "/v", "CurrentVersion"}, output); Pattern pattern = Pattern.compile("\\s*CurrentVersion\\s+\\S+\\s+(.*)$"); for (String line : output) { Matcher matcher = pattern.matcher(line); if (matcher.find()) { keyNode += "\\" + matcher.group(1); List<String> output2 = new ArrayList<>(); executeCommand( new String[] {"REG", "QUERY", "\"" + keyNode + "\"", "/v", "JavaHome"}, output2); Pattern pattern2 = Pattern.compile("\\s*JavaHome\\s+\\S+\\s+(.*)$"); for (String line2 : output2) { Matcher matcher2 = pattern2.matcher(line2); if (matcher2.find()) { pathToJavaw = Paths.get(matcher2.group(1), "bin", "javaw.exe"); break; } } break; } } try { if (Files.exists(pathToJavaw)) { return pathToJavaw.toString(); } } catch (Exception ignored) {} /* Check in 'C:\Windows\System32' */ pathToJavaw = Paths.get("C:\\Windows\\System32\\javaw.exe"); try { if (Files.exists(pathToJavaw)) { return pathToJavaw.toString(); } } catch (Exception ignored) {} /* Check in 'C:\Program Files\Java\jre*' */ pathToJavaw = null; temp = Paths.get("C:\\Program Files\\Java"); if (Files.exists(temp)) { try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(temp, "jre*")) { for (Path path : dirStream) { temp = Paths.get(path.toString(), "bin", "javaw.exe"); if (Files.exists(temp)) { pathToJavaw = temp; // Don't "break", in order to find the latest JRE version } } if (pathToJavaw != null) { return pathToJavaw.toString(); } } catch (Exception ignored) {} } /* Check in 'C:\Program Files (x86)\Java\jre*' */ pathToJavaw = null; temp = Paths.get("C:\\Program Files (x86)\\Java"); if (Files.exists(temp)) { try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(temp, "jre*")) { for (Path path : dirStream) { temp = Paths.get(path.toString(), "bin", "javaw.exe"); if (Files.exists(temp)) { pathToJavaw = temp; // Don't "break", in order to find the latest JRE version } } if (pathToJavaw != null) { return pathToJavaw.toString(); } } catch (Exception ignored) {} } /* Check in 'C:\Program Files\Java\jdk*' */ pathToJavaw = null; temp = Paths.get("C:\\Program Files\\Java"); if (Files.exists(temp)) { try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(temp, "jdk*")) { for (Path path : dirStream) { temp = Paths.get(path.toString(), "jre", "bin", "javaw.exe"); if (Files.exists(temp)) { pathToJavaw = temp; // Don't "break", in order to find the latest JDK version } } if (pathToJavaw != null) { return pathToJavaw.toString(); } } catch (Exception ignored) {} } /* Check in 'C:\Program Files (x86)\Java\jdk*' */ pathToJavaw = null; temp = Paths.get("C:\\Program Files (x86)\\Java"); if (Files.exists(temp)) { try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(temp, "jdk*")) { for (Path path : dirStream) { temp = Paths.get(path.toString(), "jre", "bin", "javaw.exe"); if (Files.exists(temp)) { pathToJavaw = temp; // Don't "break", in order to find the latest JDK version } } if (pathToJavaw != null) { return pathToJavaw.toString(); } } catch (Exception ignored) {} } return "javaw.exe"; // Let just hope it is in the path :) }