简体   繁体   English

Eclipse忽略了CLASSPATH变量?

[英]Eclipse ignoring the CLASSPATH variable?

I had the idea any java application would look up the CLASSPATH variable to check for classes at runtime. 我想到任何Java应用程序都会在运行时查找CLASSPATH变量来检查类。

But that does not seem to be the case, as a application I'm running from Eclipse. 但是,事实并非如此,因为我是从Eclipse运行的应用程序。 In which concrete situations is the CLASSPATH variable used, then? 那么,在哪种具体情况下使用CLASSPATH变量? How can I make sure Eclipse always makes use of my CLASSPATH variable? 如何确保Eclipse始终使用我的CLASSPATH变量?

The CLASSPATH variable is used when the java (or javaw) command is launched without the -classpath or -jar or -cp option. 当启动不带-classpath或-jar或-cp选项的java(或javaw)命令时,将使用CLASSPATH变量。 But Eclipse follows best practices, and always uses these options. 但是Eclipse遵循最佳实践,并且始终使用这些选项。

IMHO, you should NEVER rely on CLASSPATH. 恕我直言,您永远不要依赖CLASSPATH。 Always specify the classpath explicitely, in the command line options. 始终在命令行选项中明确指定类路径。 It's quite rare to want ALL your java programs to share the same libraries. 希望所有Java程序共享相同的库非常罕见。 That's why the CLASSPATH global environment variable is a bad idea. 这就是为什么CLASSPATH全局环境变量不是一个好主意的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM