Question

So, I recently switched from Eclipse to IntelliJ Idea, but for some reason when I run my java code, it can't find the directory where I store a file that I read in my program. I know that it works in Eclipse and when I export it as a jar file, so why doesn't it work in IntelliJ Idea? The specific error message is java.io.FileNotFoundException: /Users/Tyler/Google Drive/Java/Mac Workspace/maps/default.txt (No such file or directory)

Was it helpful?

Solution

Okay, I figured out the problem. For some reason, IntelliJ set the working directory to the folder that contains the working directory. Instead of going to /Users/Tyler/Google Drive/Java/Mac Workspace/Game/maps/default.txt like it was supposed to, it was skipping the game folder and going to /Users/Tyler/Google Drive/Java/Mac Workspace/maps/default.txt. To fix this, go to "Run" > "Edit Configurations...", and add on to the field titled "Working Directory."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top