3

In my current project settings, I have configured Eclipse to place the compiled .class files in the /bin directory.

My puzzle is that, when I run the application via the IDE and get it to print the current working directory (System.out.println(System.getProperty("user.dir")) I expect the console output to be /bin - instead the value printed is the projectRoot folder (without the /bin suffix).

If I were to navigate to the /bin folder directly, and execute my java class, the current working directory is printed as I expect it to be. What I would like is the Eclipse IDE to behave similarly.

Any ideas as to why I am observing this disparity? I have gone through many project build settings, but cannot seem to find anything that would cause this anomaly.

Kind regards, Dinuk

Dinuk
  • 1,506
  • 3
  • 16
  • 22

1 Answers1

6

In Eclipse, the working directory defaults to the project directory.
You can change this in the run properties
(Project->Properties->Run/DebugSettings->Edit->Arguments tab, at the bottom of the page).

Edit: Actually, the easiest way to get to it is Run->Open Run Dialog->Arguments tab.
It's been a while since I used Eclipse.

From an example of Eclipse Setup New Project

alt text http://apps.sourceforge.net/mediawiki/sprite2d/nfs/project/s/sp/sprite2d/a/ae/EclipseNewProjectDebugArguments.jpg

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Michael Myers
  • 188,989
  • 46
  • 291
  • 292
  • And if I were VonC, I'd add an appropriate screenshot. – Michael Myers Apr 06 '09 at 15:40
  • @mmyers: Thank you so much - I already spent 5 minutes trying to figure what could be causing this, and was afraid I would end up spending the best part of an hour looking for a hidden config setting. Thank you for the prompt response - I'll try to post a more interesting question next time :-) – Dinuk Apr 06 '09 at 15:45
  • @mmyers: all right, all right, just gimme a minute ;) +1, by the way – VonC Apr 06 '09 at 17:54
  • No, really, that's not the way I meant it. I meant that if I were you, and if I (being you) were posting an answer to this question, I (being you) would include a picture. I didn't mean that if I were you, I (being you) would go and add a picture to mmyers's post. Thanks for adding it, though. :) – Michael Myers Apr 06 '09 at 18:00
  • (I'm assuming it illustrates what I said; flickr is blocked by the proxy server here.) – Michael Myers Apr 06 '09 at 18:02
  • @mmyers: yes, I figured you meant it the way you just described. I just wanted to tease you a little bit, hence my tongue-in-cheek comment ;) – VonC Apr 06 '09 at 18:04
  • darn, flick blocked (just like for me at work, except I am posting this from home). I will check if I find a more accessible illustration. – VonC Apr 06 '09 at 18:05
  • ... and done (feel free to revert any change you might find inappropriate or not in the spirit of your original answer) – VonC Apr 06 '09 at 18:12