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:

[code lang=”java”]
public class fileGenerator {
public static void main(String[] args)
{
System.out.println(System.getProperty("user.dir"));
}
}
[/code]

Copy the path from Eclipse in your status screen and paste that into your file path. An example of that is:
[code lang=”java”]
Scanner fin = new Scanner(new File("/Users/name/java/src/filename.txt"));
[/code]

LEAVE A REPLY

Please enter your comment!
Please enter your name here