Skip to content
Advertisement

Unable to locate and load file in Eclipse IDE, File not found

I’m new to Java, and I am facing this issue in Eclipse. Even after pointing it to the correct file, it shows a file not Found Error.

I am trying to compile code from a Java file using the Java Compiler API. The code words fine in Visual Studio with setting everything in root, But gives this error in Eclipse with all these directories.

Also, why are there three different src folders in the image?

My project structure

JavaScript

Error Message

Advertisement

Answer

Your path looks wrong. The /demo directory would need to be in the root of your current drive.

Also, the output of a Maven build is found in the target directory. The Java class files are generated there, and the resource files are copied over from src/main/res hierarchy. The .Java files are lost. You could add a Maven task to copy the .Java files but this would be very nonstandard.

Finally you need to load resource files using the classpath. There are lots of examples on the Internet. Otherwise you may end up with a project that finds the file in Eclipse but not when deployed in a .jar or .war file. Happy hunting.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement