Search code examples
javaeclipseeclipse-plugineclipse-rcprcp

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


Solution

  • To read a file in your plugin: http://wiki.eclipse.org/Eclipse_Plug-in_Development_FAQ#How_do_I_read_from_a_file_that_I.27ve_included_in_my_bundle.2Fplug-in.3F