srk
srk

Reputation: 5126

Plugin project not treated as current working directory

I have a plugin project, i wanted to create & save a file in project folder.I coded in usual way,but its saving the file in the RCP installed folder in my case the rcp installed folder is

D:\RCP\eclipsercp

this is where my rcp eclipse.exe resides I tried to debug code using the following statements

System.out.println(System.getProperty("user.dir"));
System.out.println(System.getProperty("user.dir"));
System.out.println(new File (".").getAbsolutePath());
try {
    System.out.println(new File (".").getCanonicalPath());
} catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}

the output of the above statements is

D:\RCP\eclipsercp 
D:\RCP\eclipsercp\. 
D:\RCP\eclipsercp

so clearly it mean that the current working directory is the RCP installed location (i may be wrong)

In general for a normal java project the current working directory is the project itself i checked with the same above code statements its fine for a normal java project.

I am curious to know the reason behind this? And also how can i save a file in current project in an rcp i.e.., my plugin project

Upvotes: 2

Views: 1272

Answers (2)

Alexey Romanov
Alexey Romanov

Reputation: 170745

I am curious to know the reason behind this?

You aren't running your plug-in separately. All plug-ins for a single RCP application run in one process. So they all have one working directory.

And also how can i save a file in current project in an rcp i.e.., my plugin project

See FAQ How do I find out the install location of a plug-in? and FAQ Where do plug-ins store their state?.

Upvotes: 1

Related Questions