0

I have created a Maven Dynamic Web Project using Eclipse. I have created a webservice, the webservice calls a method from another class. Inside the class, i try to create a local folder in the folder of the project.

So far i have tried:

String path = new java.io.File("").getAbsolutePath();

String path = new File(".").getCanonicalPath();

String path = System.getProperty("user.dir");

String path = System.getProperty("catalina.base")

The first three returns the following path:

\eclipse\jee-mars\eclipse

The fourth statement returns the path:

\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp4

Simply, the path that i want is:

\workspace\MyProject
ykh
  • 1,775
  • 3
  • 31
  • 57

1 Answers1

1

It is dead simple. You can't not get path:

\workspace\MyProject

because your program/your code snippet not run at \workspace\MyProject.

because after compile, build to WAR file, deploy to web application server (for exampleL Apache Tomcat), your web app run inside Tomcat, not run at \workspace\MyProject.

Vy Do
  • 46,709
  • 59
  • 215
  • 313