I had installed Java on a Windows 10 system as part of the installation of the Eclipse integrated development environment (IDE), which did not add the directory where the java.exe and javac.exe executable files were installed. I could temporarily add the directory where Eclipse installed those files to the path environment variable—see Running java from an Eclipse installation from the command line—but I didn't want to continue to have to do that every time I wanted to compile a Java program at a command prompt or run one from a command-line interface (CLI). So I added the path to the executable files to the system-wide path environment variable so it would be permanent and apply to all accounts on the system. You can do so by the following steps:
advanced system settings
in
the Windows "Type here to search" field and then click on View
advanced system settings when you see that listed.
C:\Users\Jim\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_18.0.1.v20220515-1614\jre\
, since that is where Eclipse
installed the java.exe and javac.exe files. The account name will, of course,
vary depending on the account under which you installed Eclipse, when Java
wasn't previously installed on the system.
You should then be able to open a new command prompt window and run the java or javac executable programs. It won't work for a command prompt window you had open prior to updating the path environment variable, but should work in a new command prompt window.
Related articles: