Skip to main content



      Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » How do I package a file with a plug-in?
How do I package a file with a plug-in? [message #10373] Thu, 03 July 2008 14:55 Go to next message
Eclipse UserFriend
Originally posted by: richardepsilonhughes.gmail.com

I'm writing a plug-in that will encode much of its data in the form of an
XML file that it will read. I need to enclose this XML file in the JAR
file of the eventual compiled plug-in. I have two questions.

One: Is it sufficient to include the XML file in the Project folder?

Two: How do I make a Java program reference a file stored in it's own JAR?
I realize this is a shockingly basic question, but I'm not sure how to
find the answer and I figured it wouldn't require great effort to answer.
Re: How do I package a file with a plug-in? [message #10535 is a reply to message #10373] Thu, 03 July 2008 17:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richardepsilonhughes.gmail.com

I found a solution, or what I think is a solution, at
http://blog.cypal-solutions.com/2007/02/finding-install-loca tion-of-plugin.html
Re: How do I package a file with a plug-in? [message #10601 is a reply to message #10535] Thu, 03 July 2008 17:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Richard Hughes wrote:
> I found a solution, or what I think is a solution, at
> http://blog.cypal-solutions.com/2007/02/finding-install-loca tion-of-plugin.html

That is probably not the best solution.
See this thread for a better technique:
http://dev.eclipse.org/newslists/news.eclipse.platform/msg68 413.html

By the way, you can include any files you want in your plugin project.
Just make sure that they are selected in the Binary Build configuration
(on the Build tab of the manifest/plugin.xml editor) - otherwise they
won't be included when you build/package up your plugin.

Hope this helps,
Eric
Re: How do I package a file with a plug-in? [message #10664 is a reply to message #10601] Sun, 06 July 2008 12:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richardepsilonhughes.gmail.com

Thank you, Eric. I'll let you guys know how it turns out.
Re: How do I package a file with a plug-in? [message #10695 is a reply to message #10601] Sun, 06 July 2008 23:10 Go to previous message
Eclipse UserFriend
Originally posted by: richardepsilonhughes.gmail.com

Awesome! It works perfectly!


Plugin p = Activator.getDefault();
Bundle b = p.getBundle();
IPath path = new Path("/resources/resource.txt");
try {
InputStream stream = FileLocator.openStream(b, path, false);
int c = stream.read();
StringBuffer contents = new StringBuffer();
while (c != -1) {
contents.append((char) c);
c = stream.read();
}
System.out.println(contents.toString()));
} catch (IOException e) {
// Compare your lives to mine and then kill yourselves.
e.printStackTrace();
assert(false);
}
Re: How do I package a file with a plug-in? [message #571715 is a reply to message #10373] Thu, 03 July 2008 17:29 Go to previous message
Eclipse UserFriend
I found a solution, or what I think is a solution, at
http://blog.cypal-solutions.com/2007/02/finding-install-loca tion-of-plugin.html
Re: How do I package a file with a plug-in? [message #571794 is a reply to message #10535] Thu, 03 July 2008 17:50 Go to previous message
Eclipse UserFriend
Richard Hughes wrote:
> I found a solution, or what I think is a solution, at
> http://blog.cypal-solutions.com/2007/02/finding-install-loca tion-of-plugin.html

That is probably not the best solution.
See this thread for a better technique:
http://dev.eclipse.org/newslists/news.eclipse.platform/msg68 413.html

By the way, you can include any files you want in your plugin project.
Just make sure that they are selected in the Binary Build configuration
(on the Build tab of the manifest/plugin.xml editor) - otherwise they
won't be included when you build/package up your plugin.

Hope this helps,
Eric
Re: How do I package a file with a plug-in? [message #571860 is a reply to message #10601] Sun, 06 July 2008 12:27 Go to previous message
Eclipse UserFriend
Thank you, Eric. I'll let you guys know how it turns out.
Re: How do I package a file with a plug-in? [message #571890 is a reply to message #10601] Sun, 06 July 2008 23:10 Go to previous message
Eclipse UserFriend
Awesome! It works perfectly!


Plugin p = Activator.getDefault();
Bundle b = p.getBundle();
IPath path = new Path("/resources/resource.txt");
try {
InputStream stream = FileLocator.openStream(b, path, false);
int c = stream.read();
StringBuffer contents = new StringBuffer();
while (c != -1) {
contents.append((char) c);
c = stream.read();
}
System.out.println(contents.toString()));
} catch (IOException e) {
// Compare your lives to mine and then kill yourselves.
e.printStackTrace();
assert(false);
}
Previous Topic:uitestapplication in Eclipse 3.4
Next Topic:Number attributes in Extension Points
Goto Forum:
  


Current Time: Fri May 09 20:52:38 EDT 2025

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

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

Back to the top