Java 如何在 Windows 7 中设置系统环境 CLASSPATH 变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2386372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set the system environment CLASSPATH variable in Windows 7
提问by Elliott
I am trying to set the CLASSPATH variable so that my java programs can access external jars. All the jars are in one directory and using the Java 1.6 wildcard feature, I currently have assigned the CLASSPATH variable to this value:
我正在尝试设置 CLASSPATH 变量,以便我的 java 程序可以访问外部 jar。所有 jars 都在一个目录中,并使用 Java 1.6 通配符功能,我目前已将 CLASSPATH 变量分配给这个值:
C:\Program Files\Java\externaljars\*
Unfortunately, it doesn't seem to be working. Does anyone have any idea of what I am doing wrong?
不幸的是,它似乎不起作用。有没有人知道我做错了什么?
I am running Windows 7.
我正在运行 Windows 7。
采纳答案by Yannick Loriot
Your classpath is bad. You haven't to use the *. If the directory of your external jars are in the C:\Program Files\Java\externaljars you have just to add this path to your classpath like that:
你的类路径不好。您不必使用 *. 如果外部 jar 的目录在 C:\Program Files\Java\externaljars 中,则只需将此路径添加到类路径中,如下所示:
CLASSPATH = .;"C:\Program Files\Java\externaljars";
CLASSPATH = .;"C:\Program Files\Java\externaljars";
回答by codaddict
Try:
尝试:
C:\Program Files\Java\externaljars\*
Assuming externaljars is the directory that has all the jar files.
假设 externaljars 是包含所有 jar 文件的目录。