Why is the java PATH variable needed only for terminal execution?

When on the command line, you call an executable and pass it a file as an argument. Since it does not know where this executable is, you either need to call it with an absolute path (Includes the entire path from the drive letter to the executable) or the executable must be present in one of the locations listed in the system PATH environment variable.

However, when double clicking a file Windows does not have the luxury of being told which application it should use ahead of time. To solve this issue, Windows keeps a global registry of programs, file extensions, and various metadata about them. This includes stuff like which icon to display for that file type, the path to the executable used to open that file, extensions associated with a given program, the path to the uninstaller to use if deleted from the control panel, and much more.

The Java installer handles updating the registry for you behind the scenes so you don't need to, however depending on your installation setting it may not update the system path since most people will only use the double clicking method.