环境变量 - 如何在PATH中包含所有子文件夹

时间:2021-08-17 11:41:57

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)

未捕获的错误提取图像:sun.awt.image.URLImageSource.getDecoder(未知来源)sun.awt.image.InputStreamImageSource.doFetch(未知)sun.awt.image.URLImageSource.getConnection(未知来源)的java.lang.NullPointerException来自sun.awt.image.ImageFetcher.run(未知来源)的sun.awt.image.ImageFetcher.fetchloop(未知来源)

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.

此文件夹包含许多子文件夹和子文件夹的子文件夹 - 是否有一种简单的方法可以将所有这些路径放入PATH环境变量中?我相信环境变量不包含子文件夹,我是否正确?我使用的是Windows XP,如果有帮助的话。

Thank you very much for your time.

非常感谢您的宝贵时间。

3 个解决方案

#1


2  

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.

    “PATH”变量是命令shell用于查找可执行文件的变量。不是JAR文件,不是.class文件,不是源代码,不是数据文件。只是可执行文件。

  • 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.

因此,在PATH变量中添加一堆东西并没有帮助。

But to answer your questions:

但要回答你的问题:

is there an easy way to put all these paths into the PATH environment variable?

是否有一种简单的方法将所有这些路径放入PATH环境变量?

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.

对于Windows,我不知道。对于Linux,你可以使用find等一些简单的脚本来完成这个。但是在Windows上这样的东西并不那么容易......根据我的经验。

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.)

另一方面,Windows和Unix / Linux命令shell将PATH环境解释为要搜索命令的目录列表。标准shell不搜索PATH目录的子目录。 (从理论上讲,你可以实现一个shell,如果你这么做的话可以做到这一点,并且有几周/几个月/年的业余时间来完成它。)

#2


1  

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?

您必须了解向PATH添加目录时会发生什么。每次尝试调用可执行文件(不指定绝对路径)时,都会按顺序搜索PATH中的所有目录,直到找到与该名称匹配的可执行文件。你真的想要那种详尽的搜索吗?

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!

没有软件是如此复杂,你会强迫你在PATH中包含一个巨大的目录层次结构。大多数项目可能有一个或少数包含二进制图像的目录。我的建议是找到你需要的确切目录!

#3


-1  

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.

Uncaught错误提取图像:java.lang.NullPointerException超级模糊。它表明图像丢失了。在执行程序时,我不得不添加2个类路径但在最后一个末尾忘记了一个逗号。因此,当我添加逗号时,程序似乎运行愉快。

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给了我错误。

java -cp "/path/to/binfile";"/path/to/anotherbinfile"; name.name1.name2.name2 fixed it.

java -cp“/ path / to / binfile”;“/ path / to / anotherbinfile”; name.name1.name2.name2修复了它。

#1


2  

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.

    “PATH”变量是命令shell用于查找可执行文件的变量。不是JAR文件,不是.class文件,不是源代码,不是数据文件。只是可执行文件。

  • 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.

因此,在PATH变量中添加一堆东西并没有帮助。

But to answer your questions:

但要回答你的问题:

is there an easy way to put all these paths into the PATH environment variable?

是否有一种简单的方法将所有这些路径放入PATH环境变量?

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.

对于Windows,我不知道。对于Linux,你可以使用find等一些简单的脚本来完成这个。但是在Windows上这样的东西并不那么容易......根据我的经验。

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.)

另一方面,Windows和Unix / Linux命令shell将PATH环境解释为要搜索命令的目录列表。标准shell不搜索PATH目录的子目录。 (从理论上讲,你可以实现一个shell,如果你这么做的话可以做到这一点,并且有几周/几个月/年的业余时间来完成它。)

#2


1  

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?

您必须了解向PATH添加目录时会发生什么。每次尝试调用可执行文件(不指定绝对路径)时,都会按顺序搜索PATH中的所有目录,直到找到与该名称匹配的可执行文件。你真的想要那种详尽的搜索吗?

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!

没有软件是如此复杂,你会强迫你在PATH中包含一个巨大的目录层次结构。大多数项目可能有一个或少数包含二进制图像的目录。我的建议是找到你需要的确切目录!

#3


-1  

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.

Uncaught错误提取图像:java.lang.NullPointerException超级模糊。它表明图像丢失了。在执行程序时,我不得不添加2个类路径但在最后一个末尾忘记了一个逗号。因此,当我添加逗号时,程序似乎运行愉快。

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给了我错误。

java -cp "/path/to/binfile";"/path/to/anotherbinfile"; name.name1.name2.name2 fixed it.

java -cp“/ path / to / binfile”;“/ path / to / anotherbinfile”; name.name1.name2.name2修复了它。