开发者

Plugin project not treated as current working directory

开发者 https://www.devze.com 2023-03-30 23:14 出处:网络
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

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(Sy开发者_如何转开发stem.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


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


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?.

0

精彩评论

暂无评论...
验证码 换一张
取 消