1

When I run this code on my MAC OS X in an eclipse web project

File file1 = new File("myfile.txt");
if( !file1.exists() ) file1.createNewFile();
System.out.println( file1.getAbsolutePath() );

it says

/Users/Richard/Desktop/eclipse/Eclipse.app/Contents/MacOS/myfile.txt

on my WINDOWS 7 computer it says

C:\Users\Richard\Documents\workspace\myproject\src\com\example\myclass\myfile.txt

How do I get my eclipse running on my MAC OS X to output files in my Documents folder like on my WINDOWS 7, instead of going into the Eclipse.app APP BUNDLE and being put into the folder Contents/MacOS ?

RichardW
  • 249
  • 4
  • 8

2 Answers2

2

You can change the working directory for any given launch configuration under Run -> Run Configurations... then under the Arguments tab.

It's strange that your default seems to be within the Eclipse.app bundle—normally, it's ${workspace_loc:project name}.

Unfortunately, it seems you still can't set the default working directory for all new run configurations.

Community
  • 1
  • 1
Alistair A. Israel
  • 6,417
  • 1
  • 31
  • 40
0

If you're on Mac, then:

  1. Open the 'Servers' tab.

  2. Double click your server.

  3. Click 'Open launch configuration'.

  4. Click the 'Arguments' tab.

  5. In the 'Working directory' pane, choose 'Other' and enter the path you want to have as your working directory.

barak manos
  • 29,648
  • 10
  • 62
  • 114