environment variables - how to include all subfolders in PATH
I am in the process of debugging and want to make it so that the environment path includes all paths in a folder because a program that I am trying to get running is NOT cooperating and is giving extremely vague errors like:
Uncaught error fetching image: java.lang.NullPointerException at sun.awt.image.URLImageSource.getConnection(Unknown Source) at sun.awt.开发者_开发知识库image.URLImageSource.getDecoder(Unknown Source) at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source) at sun.awt.image.ImageFetcher.fetchloop(Unknown Source) at sun.awt.image.ImageFetcher.run(Unknown Source)
This folder has many subfolders and subfolders of subfolders -- is there an easy way to put all these paths into the PATH environment variable? I believe environment variables do not include subfolders, am I correct? I am using Windows XP, if that helps.
Thank you very much for your time.
You are almost certainly going about this the wrong way:
The "PATH" variable is what the command shell uses to find executables. Not JAR files, not .class files, not source code, not data files. Just executables.
Your exception is not caused by a missing executable.
The paucity of information in your stacktraces is not caused by a missing executable.
So adding a whole pile of stuff to your PATH variable is not going to help.
But to answer your questions:
is there an easy way to put all these paths into the PATH environment variable?
I don't know for Windows. For Linux you could do this with some simple scripting using find
etc. But stuff like that isn't so easy on Windows ... in my experience.
I believe environment variables do not include subfolders, am I correct?
That is not a meaningful question. Environment variables include whatever characters you put into them. They neither know or care what those characters mean.
On the other hand, the PATH environment is interpreted by Windows and Unix / Linux command shells as a list of directories to be searched for commands. The standard shells don't search subdirectories of the PATH directories. (In theory, you could implement a shell that did that if your were so inclined, and had a few weeks / months / years of spare time to do it.)
You've to understand what happens when you add a directory to PATH. Every time you try to invoke an executable (without specifying an absolute path), all the directories in the PATH are searched in order until an executable that matches the name is found. Do you really want that exhaustive search?
No software is so complex that would you force you to include a huge directory hierarchy into the PATH. Most projects probably have one or a handful of directories that contain the binary images. My suggestion is to find the exact directory you need!
I found the answer to my problems and just wanted to share with you want happened, in case it helps out a poor soul in the future.
The Uncaught error fetching image: java.lang.NullPointerException
is super vague. It suggests that an image is missing. In executing the program, I had to add 2 classpaths but forgot a comma at the end of the last one. Thus, when I added the comma back, the program seems to run happily.
For example: java -cp "/path/to/binfile";"/path/to/anotherbinfile" name.name1.name2.name2 gave me the error.
java -cp "/path/to/binfile";"/path/to/anotherbinfile"; name.name1.name2.name2 fixed it.
精彩评论