Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ Idea can't find directory

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)

like image 580
Tyler Avatar asked Oct 21 '25 09:10

Tyler


1 Answers

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."

like image 74
Tyler Avatar answered Oct 24 '25 00:10

Tyler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!