Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Filelocator not working in exe
Filelocator not working in exe [message #657838] Fri, 04 March 2011 10:02 Go to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member
i want to get the os location of a file in one my plugins

when i run the code in eclipse environment it works fine but when i export my product as exe it fails

here is my code snippet

Bundle bundle=Platform.getBundle("com.genesyslabs.sipserver.mist.generator");
		if(bundle!=null)
		{
		System.out.println("\n bundle:"+bundle.getSymbolicName()+"\n");		
		}
		IPath pt=new Path("src/workflow/generator.oaw");
		URL url = FileLocator.find(bundle,pt, null);		
		String wfFile = ""; 
		System.err.println("\n wFUrl"+"\n");
		String srcgen="/C:/";
		 try  	{
			 
			 if(url!=null)
				 {
				 URL fileURL = FileLocator.toFileURL(url);
				 wfFile=fileURL.getFile().toString();
				 System.out.println("\nurl:"+url.getPath()+"\n");
				 System.out.println("\n wfFile:"+wfFile+"\n");
				 }
				else
				{					
					System.out.println("\n url:"+"could not  get the url"+"\n");
					wfFile="C:\\Documents and Settings\\rtiragat\\dummy workspace\\com.genesyslabs.sipserver.mist.generator\\src\\workflow\\generator.oaw";
					System.out.println("\n using the default hard coded workflow location \n");
				}



-----------------------------

in url variable is null i.e url is not pointing to any object when i execute it as an exe in win32


please give me a way how i can get the os location of the file


Thanks
Ravi
Re: Filelocator not working in exe [message #657859 is a reply to message #657838] Fri, 04 March 2011 11:30 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 04/03/11 3:32 PM, Ravi Kiran wrote:
> IPath pt=new Path("src/workflow/generator.oaw");

The src folder will not be available when you export your bundle. You
should give the relative path within the jar.

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Filelocator not working in exe [message #657897 is a reply to message #657859] Fri, 04 March 2011 14:41 Go to previous messageGo to next message
Ravi Kiran is currently offline Ravi KiranFriend
Messages: 41
Registered: December 2010
Member

Hi prakash


Thanks for replying

i didn't include the src folder in the binary build of the required plug in so i was not able to get the location


Regards
Ravi


Re: Filelocator not working in exe [message #657901 is a reply to message #657897] Fri, 04 March 2011 14:49 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 03/04/2011 09:41 AM, Ravi Kiran wrote:
>
> Hi prakash
>
> Thanks for replying
> i didn't include the src folder in the binary build of the required plug
> in so i was not able to get the location

That's not a good idea or generally accepted practice.

Files in your <project>/src directory are considered standard java
resources. You would access them using:
class.getResourceAsStream("/workflow/generator.oaw"); or simply
class.getResource(*)

That won't change while running in eclipse or once it is deployed.


bundle-type resources are accessed through Bundle.getEntry(*). i.e. if
you have <project>/icons that you include in your bundle from your
build.properties. They are a good candidate for
FileLocator.toFileURL(*), as they are not available through
class.getResourceAsStream(*). As they're available from the root of
your project, Bundle.getEntry(*) will work both inside eclipse and once
it is deployed.

You should look at your generator.oaw file and decide what kind of
support you need. If you can simply make it a java resource, go for it.
If not, then consider placing it similar to how icons are provided in
most eclipse plugins.

Later,
PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:How to set the Editor size?
Next Topic:Helios Internal browser fails for JSF - FireFox OK
Goto Forum:
  


Current Time: Thu Apr 25 23:09:34 GMT 2024

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

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

Back to the top