0

In a java web project in eclipse deployed in tomcat,here is the code snippet

File file = new File(".");
System.out.println(file.getAbsolutePath());

and it prints out

D:\Program_Files\eclipse\.

which is the eclipse's root installation directory,I know that "." refer to a path means the path where java command runs,but why the path is D:\Program_Files\eclipse\.?
I found some other people test this code snippet,and they prints the path as %tomcat_home%/bin,how can I set to get the same code result of %tomcat_home%/bin?

jacky
  • 649
  • 1
  • 8
  • 22
  • 3
    Why do you need this? HINT: Obviously the current directory will vary depending on the environment: running Tomcat standalone, debugging with Eclipse, *running in production*. You should make your code independent of the exact location of the current directory. – Nikos Paraskevopoulos Jan 03 '17 at 16:59
  • @Nikos Paraskevopoulos Thanks for your advise, I just came across this difference from other people's code result and try to know what's the reason is,:) – jacky Jan 03 '17 at 17:04

0 Answers0