Java - Eclipse上的类路径问题 [英] Java - Problem with the classpath on Eclipse

查看:157
本文介绍了Java - Eclipse上的类路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重新编译我一直在使用的项目,并且尝试加载属性文件时,我会收到一条错误消息:

I'm trying to recompile a project I've been working on and I keep getting an error message when trying to load a property file:


The system cannot find the path specified.

我想这与classpath有关。但是我已经在Properties-> Java build path-> Libraries(external class)中添加了该文件的路径。
我还检查了eclipse生成的.classpath文件,路径真的在那里!

I guess this has to do with the classpath. But I've added the path to the file in Properties-> Java build path-> Libraries (external class). I also checked the .classpath file generated by eclipse, and the path is really there!

为什么Eclipse看不到正确的路径? p>

Why isn't Eclipse looking at the right path?

推荐答案

有2个不同的类路径,构建类路径和运行时类路径。您正在设置的是构建类路径。

There 2 different classpaths, build classpath and runtime classpath. The one you are setting is the build classpath.

查看运行时类路径,转到运行 - >运行配置并选择您的应用程序配置。检查类路径设置。

Check your runtime classpath by going to Run -> Run Configurations and select your application configuration. Check the classpath setting there.

此外还有另一种解决方法。默认情况下,Eclipse将包含您的类路径中的输出文件夹(通常命名为 bin )。通常,在 src 文件夹中不可编译的东西将被复制到 bin 。我假设您的资源文件不在 src 文件夹中。您可以做的是打开项目属性,并将您的属性所在的文件夹添加到 Java Buld Path - >来源(标签)。这样eclipse将将该文件夹的内容复制到 bin 中,并将在类路径中。

There is another workaround for this also. Eclipse by default will include your output folder (usually named bin) in your classpath. Typically anything that are not compilable in src folder will be copied to bin as is. I assumed your property file is not located in src folder. What you can do is to open your project property and add the folder where your property is located into Java Buld Path -> Source (tab). This way eclipse will copy the content of that folder into bin and will be in the classpath.

这篇关于Java - Eclipse上的类路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆