0

I have a Java project with a structure like this:

  • root
    • swt.package with Main Class inside
    • data.package
    • other.package

What I need is the to get root path in my Main class.

On IntelliJ this works perfectly with System.getProperty("user.dir") that gives me the exact path to my root folder.

But on eclipse this returns root/swt.package.

How can I get the same path to the root folder independend of my IDE?

Tristate
  • 1,498
  • 2
  • 18
  • 38
  • 3
    You can use `user.dir`, but you have to configure the Run Configuration in Eclipse to start the program in that directory. – daniu Nov 12 '19 at 10:53
  • it is kind of *strange* to need the root path of your project, unless developing some plugin for the IDE (which would conflict with being IDE-independent) - what is expected after deployment? (`user.dir` will retrieve the current working directory when the application was started) – user85421 Nov 12 '19 at 10:55
  • Check out https://stackoverflow.com/questions/3153337/how-to-get-current-working-directory-in-java/3153413#3153413 – Smile Nov 12 '19 at 10:56

0 Answers0