I have implemented the Java QuickStart for the Classroom API and am getting an error message "java.io.FileNotFoundException: Resource not found: /credentials.json" at run-time. I copied my credentials.json file to the Project res directory, but continue to get this error. Any suggestions?
Asked
Active
Viewed 5,509 times
3
-
1Double check the file name and path. – Jonas Dec 11 '19 at 19:45
-
Did you create a folder "src/main/java/" and are both your .java file and your credentials.json file inside this folder? – ziganotschka Dec 12 '19 at 10:02
4 Answers
5
I tried it in a different way than I found on other websites, and it worked for me.
replace below code:
InputStream in = GoogleSheetAPIHandler.class.getClass().getResourceAsStream(CREDENTIALS_FILE_PATH);
With this code:
InputStream in = new FileInputStream(CREDENTIALS_FILE_PATH);

Abdul Samad
- 51
- 5
1
You need to import credential.json file into the src/main/resources folder in eclipse. You may be included in the project folder. But you need to import it into eclipse.
- locate your credentials.json file in the folder.
- click and drag it
- drop it in src/main/resource and click ok.
- After importing into eclipse it should show like the below image.

Satheeshkumar
- 75
- 3
- 12
1
There are two steps needed to find the resource in Eclipse:
- To have the file in the resources folder
- Create the resource folder (if it does not exist): src/main/resouces
- Add the credential file to the resource folder: src/main/resouces/credential.json
- To have the resources folder in the Source Java Build Path
- Go to Eclipse Path Source: Project > Properties > Java Build Path > Source (tab)
- Add resources folder: Add Folder ... (button) > resources (check box) > OK (button)

j.xavier.atero
- 506
- 2
- 10
- 25
0
The name of your file has to be credentials only, if you have credentials.json as the name of your file in your folder you will get this error.

Stefan
- 25
- 7