7

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.

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!

Why isn't Eclipse looking at the right path?

3 Answers 3

26

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.

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.

Sign up to request clarification or add additional context in comments.

1 Comment

why i cant see classpath in Run configuration . i am using Eclipse luna. i can see this tabs Main, Argument plugins, configuration,Tracing,Enviroment,Common.
1

There are several ways to read a property file:

  • Have it in the current working directory (the one cd'ed to). You can do this in the Eclipse launch configuration. (Run -> Run...)

  • Include it in your application, by having it in a source folder. You then need to read it in through a class loader to be able to get it always (when jarred up, through Java Web Start, etc).

Comments

0

Double check if the property file or its directory is in the excluded list of the project Source. If it is remove the exclusion filter and try recompiling.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.