RichardW
RichardW

Reputation: 259

Eclipse on MAC, set current directory to be in Documents folder not APP BUNDLE

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 ?

Upvotes: 1

Views: 2206

Answers (2)

barak manos
barak manos

Reputation: 30136

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.

Upvotes: 0

Alistair A. Israel
Alistair A. Israel

Reputation: 6567

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.

Upvotes: 2

Related Questions