Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » determining Eclipse or Eclipse plug in location at run time
determining Eclipse or Eclipse plug in location at run time [message #461508] Thu, 11 January 2007 01:11 Go to next message
Eclipse UserFriend
Originally posted by: ramapra.gmail.com

Hi ,

I have a plug in and need to save some user information . To do this I
was thinking of using a File , but I need to specify the location of the
file . I want the file to ideally be in the same folder as my plug in (
.../eclipse/plugins/MyPlugin)


Basically I need a mechanism where I am storing this file under MY plugin
directory.


Is there an API or mechanism that provides the location of the currently
running plugin ?


I am running on Linux and When i check for the current working directory
it returns /root


Thanks
Re: determining Eclipse or Eclipse plug in location at run time [message #461511 is a reply to message #461508] Thu, 11 January 2007 03:07 Go to previous messageGo to next message
Gavin Bong is currently offline Gavin BongFriend
Messages: 23
Registered: July 2009
Junior Member
Read http://wiki.eclipse.org/index.php/FAQ_Where_do_plug-ins_stor e_their_state%3F
Re: determining Eclipse or Eclipse plug in location at run time [message #461523 is a reply to message #461511] Thu, 11 January 2007 10:35 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
Yeah, and to follow it up, you shouldn't assume that (a) myplugin is a directory, or (b) that it's writable. You certainly shouldn't expect to get out resources via a java.io.File object.

Look for the getPluginStateLocation(), and if you need to instantiate a template, access it from the plugin with getClass().getResourceAsStream("/the.template.txt"), then pass that to whatever stream is expecting to read from it. You can then dump it out to the plugin state location later.

Alex.
Re: determining Eclipse or Eclipse plug in location at run time [message #461544 is a reply to message #461523] Thu, 11 January 2007 19:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ramapra.gmail.com

Thank you everyone for the responses . I had one question regarding the
process of Writing


You were suggesting that I not use java.io. classes


How would i write to this same resource ?
Re: determining Eclipse or Eclipse plug in location at run time [message #461550 is a reply to message #461544] Fri, 12 January 2007 00:04 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

I think Alex was saying for reading defaults or templates out of your
plugin, don't use java.io.File, just use getResource(*) or
getResourceAsStream(*).

To write to your plugin state location, it's OK to use java.io.File,
Writer, etc.

Later,
PW


Previous Topic:Help! How to Debug in RCP Development?
Next Topic:how to change the color of the title bar of RCP product
Goto Forum:
  


Current Time: Thu Apr 18 16:03:44 GMT 2024

Powered by FUDForum. Page generated in 0.02133 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top