I am confused about how the current working directory is set in different Eclipse projects.
I have 2 Java applications I am running in Eclipse. One is a regular Java project, the other a J2EE servlet (Dynamic Web Project). At the top of each application I have this code:
File currentDirectory = new File(new File(".").getAbsolutePath());
System.out.println(currentDirectory.getAbsolutePath());
System.out.println(currentDirectory.getCanonicalPath());
System.out.println(System.getProperty("user.dir"));
Java project output:
C:\svn-source\Executor\.
C:\svn-source\Executor
C:\svn-source\Executor
J2EE project output:
C:\java\eclipse-jee-indigo-SR2-win32\eclipse\.
C:\java\eclipse-jee-indigo-SR2-win32\eclipse
C:\java\eclipse-jee-indigo-SR2-win32\eclipse
Why in the case of the Web project do I get the Eclipse root installation folder when the project I created is in a completely different place? Am I using the right classes for getting the current working directory? If so, could somebody please explain how the CWD is determined in each case (Java project vs the Web project).
Thanks.