When a new version of JRE is installed, this path C:\Program Files (x86)\Common Files\Oracle\Java appears to be updated with executables corresponding to the new JRE version. The problem is this would be JRE and not JDK. So, programs that depend on JDK (IDE for example) will fail to launch.

Here is how I get it to work consistently

  1. I always have an environment variable in User Variables (System Environment Variables by going to Control Panel -> System -> Advanced System Settings -> Environment Variables -> User Variables) -- JAVA_HOME pointing to the JDK Home. And add %JAVA_HOME%\bin to the PATH environment variable.
  2. Interestingly, I remove the entry C:\Program Files (x86)\Common Files\Oracle\Java\javapath from the Path environment variable in System Environment Variables (Control Panel -> System -> Advanced System Settings -> Environment Variables -> System Variables).

This works as of Aug 2020 for Windows 10 (1903), Java 8u251. :)

Answer from Rakesh N on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › nio › file › Path.html
Path (Java Platform SE 8 )
April 21, 2026 - Java™ Platform Standard Ed. 8 ... An object that may be used to locate a file in a file system. It will typically represent a system dependent file path.
🌐
Baeldung
baeldung.com › home › java › java io › java – path vs file
Java – Path vs File | Baeldung
April 20, 2024 - In Java, Path and File are classes responsible for file I/O operations.
Discussions

How to best set the path to java in windows - Stack Overflow
And I have seen that the first one, the javapath, gets updated with the latest java sdk I have installed. However, most of what you google tells you should set the environment variable PATH to the latest, the one with the jdk in the path. So what is the best, how do they work. More on stackoverflow.com
🌐 stackoverflow.com
debian - How to specify filepath in java? - Stack Overflow
I have created a java application for "Debian Linux." Now I want that that application reads a file placed in the directory where the jar file of that application is specified. So what to specify at the argument of the File Object? ... What to specify as argument for the above statement to specify relative filepath representing the path ... More on stackoverflow.com
🌐 stackoverflow.com
Java: Path vs File - Stack Overflow
You can read Oracle's comments on the differences here: docs.oracle.com/javase/tutorial/essential/io/legacy.html 2015-01-26T21:15:42.853Z+00:00 ... Also note that "Files" (in the plural) is not deprecated. It is essentially an abstract class that operates on Path objects and performs many of ... More on stackoverflow.com
🌐 stackoverflow.com
rhel - How to find path where jdk installed? - Unix & Linux Stack Exchange
I've installed jdk1.7.0.rpm package in RHEL6. Where I do find the path to execute my first java program? More on unix.stackexchange.com
🌐 unix.stackexchange.com
🌐
Medium
medium.com › @AlexanderObregon › javas-paths-get-method-explained-9586c13f2c5c
Java’s Paths.get() Method Explained | Medium
September 8, 2024 - Understanding the difference between relative and absolute paths is crucial when working with Paths.get(). Paths in Java can either be absolute, meaning they specify the location of a file or directory from the root of the file system, or relative, ...
🌐
Oracle
java.com › en › download › help › path.html
How do I set or change the PATH system variable?
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › nio › file › Path.html
Path (Java SE 11 & JDK 11 )
January 20, 2026 - Paths associated with the default provider are generally interoperable with the java.io.File class. Paths created by other providers are unlikely to be interoperable with the abstract path names represented by java.io.File. The toPath method may be used to obtain a Path from the abstract path name represented by a java.io.File object.
Find elsewhere
🌐
Dev.java
dev.java › learn › java-io › file-system › path
Working with Paths - Dev.java
January 25, 2023 - A Path instance contains the information used to specify the location of a file or directory. At the time it is defined, a Path is provided with a series of one or more names. A root element or a file name might be included, but neither are required.
🌐
Dev.java
dev.java › learn › java-io › file-system › file-path
Accessing Resources using Paths - Dev.java
January 25, 2023 - How to access resources using the Path interface, and how to refactor your old-style File code to using Path.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-nio-file-paths-class-in-java
java.nio.file.Paths Class in Java - GeeksforGeeks
March 12, 2021 - Returns a Path by converting given strings into a Path. If "more" doesn't specify any strings than "first" is the only string to convert. If "more" specify extra strings then "first" is the initial part of the sequence and the extra strings will be appended to the sequence after "first" separated by "/". ... // Java program to demonstrate // java.nio.file.Path.get(String first,String...
🌐
W3Schools
w3schools.com › java › java_files_read.asp
Java Read Files
File name: filename.txt Absolute path: C:\Users\MyName\filename.txt Writeable: true Readable: true File size in bytes: 0 Run Example » · There are several classes you can use to read files in Java:
🌐
Oracle
docs.oracle.com › javase › tutorial › essential › io › pathOps.html
Path Operations (The Java™ Tutorials > Essential Java Classes > Basic I/O)
A Path instance contains the information used to specify the location of a file or directory. At the time it is defined, a Path is provided with a series of one or more names. A root element or a file name might be included, but neither are required.
🌐
Reddit
reddit.com › r/javahelp › java adding to path
r/javahelp on Reddit: java adding to path
August 5, 2023 -

what does adding java to path does on windows? I started a local java short course sometime ago but I had to differ it. I started watching some online tutorials but none of them added java "to path" (system properties ->Environment Variables -> click on path -> click edit -> click new paste (C:\Program Files\Java\jdk-17\bin) which I did in the local course I joined.

Top answer
1 of 3
10
Adding something to the path just makes the commands in the folder available everywhere system wide. The way an OS (not limited to Windows) works is that it searches certain folders for the commands you enter in the terminal (console). If it doesn't find the command, it tells you that the command you entered is not recognized. By adding a folder to the path you tell the OS to also search that particular folder when you enter a command. For Java, you need javac and java from the console. The former compiles your source code, the latter executes it. Had you not added the folder to the path, you would always need to type C:\Program Files\Java\jdk-17\bin\javac when you want to compile a program. By adding the folder to the path javac becomes sufficient.
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
TutorialsPoint
tutorialspoint.com › java_nio › java_nio_path.htm
Java NIO - Path
Technically in terms of Java, Path is an interface which is introduced in Java NIO file package during Java version 7,and is the representation of location in particular file system.As path interface is in Java NIO package so it get its qualified ...
🌐
Oracle
java.com › en › download › help › java_mac.html
Installing and using Oracle Java on macOS
When I try to use java from the command line, why doesn't it work? I have Oracle's version of the JRE installed. Installing JRE from Oracle does not update java -version symlinks or add java to your path. For this functionality, you must install the full JDK.