How to get resource from JarPackageFragmentRoot?
For example fo开发者_Go百科r junit.jar I use getResource() and it returns null.
IResource
s only exist for parts of the file system that are in the workspace. Since junit.jar is outside the workspace, there is no corresponding 'IResource' for it. Eclipse's workspace handling is an abstraction over the underlying filesystem. Only files inside the workspace are included.
However, there are some possibilities:
- You can call the
getJar()
method. It does not return an IResource, but it may be suitable for your purposes. - You can import the junit.jar file into your workspace and then call
getResource()
on it.
Neither of which are exactly what you want, most likely, but you need to realize that your stated goal is not what the Eclipse resource abstraction provides.
精彩评论