psun
psun

Reputation: 635

Java - Resources.getresource() java.lang.IllegalArgumentException: resource "file" not found

I'm calling the generateTopKFrequentPattern() method of FP growth mining in the Apache Mahout library. In that call, when I use Resources.getResource("FILENAME"), I get the above error saying the file is not found.

My directory structure is Application/src/FILENAME. In the Eclipse window, from run configurations, the default classpath is "Application". I tried using an absolute classpath, "Application/src/FILENAME" and "src/FILENAME". I Still have the same error.

Can anyone please help me with this?

Upvotes: 0

Views: 6787

Answers (2)

Mingyu
Mingyu

Reputation: 33349

The issue is that the resource, in this case the file, is not in the build path.

If you are using Eclipse, right click the file, and select Add to Build Path.

Upvotes: 0

psun
psun

Reputation: 635

@Thilo, /FILENAME didn't work.

The file should be in the same folder as the classpath (location of the .class file). Either moving the data file to the location of classpath or changing the location of classpath to that of the data file solved the error.

Earlier I had set the classpath location same as the data file location. Somehow, the configuration was reset in Eclipse.

In my case the classpath is "Application/bin" and file is in "Application/src/FILENAME". Specifying file path relative to classpath say "../src/FILENAME" or "/../src/FILENAME" also didn't work for me.

Upvotes: 1

Related Questions