Solved: How to Find the Eclipse path on Mac or Windows

0

If you are using Eclipse to work on Java programming and need to import a file but get an error it’s most likely your path. After a lot of searching and reading through dozens of posts I have found the solution. Create a class called “FileGenerator” and add the following code:

public class fileGenerator {      
public static void main(String[] args)
{
System.out.println(System.getProperty("user.dir"));
}
}

Copy the path from Eclipse in your status screen and paste that into your file path. An example of that is:

Scanner fin = new Scanner(new File("/Users/name/java/src/filename.txt"));

LEAVE A REPLY