How To Access Folders When Testing Plugins [message #328046] |
Tue, 13 May 2008 01:47  |
Eclipse User |
|
|
|
Originally posted by: gautam_hn.yahoo.com
Hi friends,
I've searched enough to find a solution for this particular issue, all in
waste.
Here's the situation I'm facing now.
I have two projects in Eclipse, lets say :
com.test.PluginProject (plugin project)
com.test.JavaProject (java project)
PluginProject has the business logic and JavaProject is dependant on
PluginProject. Everything works pretty much fine, except for, there are
some folders in the JavaProject which I'm not able to get a handle to,
when I launch the plugin for testing.
com.test.PluginProject -- depends on
com.test.JavaProject
-- Folder
-- Sub-Folder1
-- Sub-Folder2
-- Internal-Folder1
-- Internal0Folder2
I want to browse through the contents of the folder and subfolders and
internal folders.
this.getClassloader().getResource()
gets the URL (Absolute), but since my launched application I won't be able
to create a file object.
Any lead on this one will be helpful. I'm not sure if this is the right
approach, suggestions to do it right way much appreciated.
Thanks,
/G
|
|
|
Re: How To Access Folders When Testing Plugins [message #328065 is a reply to message #328046] |
Tue, 13 May 2008 10:16  |
Eclipse User |
|
|
|
You could try setting the working directory in the launch configuration
to the root of your com.test.JavaProject. Look for "Working directory"
on the "Arguments" page.
With the working directory set, you should be able to access the root of
your project with new File(".") and navigate from there.
Note that this won't work if you package your project up as a JAR for
delivery. I assume that this won't be a problem since you said that this
is for testing (I'm assuming development/unit testing in the Eclipse
environment). As a general rule, the getResource() and
getResourceAsStream() are the safe way to go.
HTH,
Wayne
On Tue, 2008-05-13 at 05:47 +0000, Exquisitus wrote:
> Hi friends,
>
> I've searched enough to find a solution for this particular issue, all in
> waste.
> Here's the situation I'm facing now.
>
> I have two projects in Eclipse, lets say :
>
> com.test.PluginProject (plugin project)
> com.test.JavaProject (java project)
>
> PluginProject has the business logic and JavaProject is dependant on
> PluginProject. Everything works pretty much fine, except for, there are
> some folders in the JavaProject which I'm not able to get a handle to,
> when I launch the plugin for testing.
>
> com.test.PluginProject -- depends on
> com.test.JavaProject
> -- Folder
> -- Sub-Folder1
> -- Sub-Folder2
> -- Internal-Folder1
> -- Internal0Folder2
>
> I want to browse through the contents of the folder and subfolders and
> internal folders.
>
> this.getClassloader().getResource()
>
> gets the URL (Absolute), but since my launched application I won't be able
> to create a file object.
>
> Any lead on this one will be helpful. I'm not sure if this is the right
> approach, suggestions to do it right way much appreciated.
>
> Thanks,
> /G
>
|
|
|
Powered by
FUDForum. Page generated in 0.06592 seconds