Home » Language IDEs » Java Development Tools (JDT) » To create a IJavaElement out of a class in a jar?
To create a IJavaElement out of a class in a jar? [message #114354] |
Thu, 06 November 2003 11:15  |
Eclipse User |
|
|
|
Originally posted by: vgusev.graphlogic.com
Hello,
I am looking for any suggestions about creating a IJavaElement for a class
that resides in an external jar. Do I need to go through creating IRecource
for a jar, and then user JavaCore.create(IResource)? Then get IJavaElement
out of the result? Is the IProject required for any of this?
I would greatly appreciate any pointers. Thanks.
Vladimir
|
|
| | | | |
Re: To create a IJavaElement out of a class in a jar? [message #114664 is a reply to message #114424] |
Fri, 07 November 2003 06:12   |
Eclipse User |
|
|
|
Sorry I don't know what the JDO persitence store is, so I cannot help you
here.
Jerome
"Vladimir" <vgusev@graphlogic.com> wrote in message
news:boe26f$iio$1@eclipse.org...
> The questions I am going to ask are what is the TypeHierarchy of this
> class - I want to pass this java element to the TypeHierarchyViewer. My
> class instance is loaded from the JDO persistence store, it is described
in
> a local jar - I need to present its relationships exactly as in the type
> browser. Please confirm that for this scenario I have to have a fake
project
> (I hate the idea to have it). Thanks again.
>
> Vladimir
> "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> news:bodvif$ftl$1@eclipse.org...
> > If all you wanted is get the IClassFile handle, the code below would
work
> > without the project existing.
> > But I assume that your going to ask questions to this handle. If the
> project
> > doesn't exist, those will throw a JavaModelException.
> > So yes, you need to create a fake Java project and add your external jar
> to
> > its classpath before you can use the IClassFile handle.
> >
> > Jerome
> >
> > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > news:bodtcj$d4s$1@eclipse.org...
> > > Jerome,
> > >
> > > Thanks for a swift response! Does it mean that I _must_ have a project
> > > present? I am trying to do this for a class that is not related to a
> java
> > > project per se - in an application that has nothing to do with java
> > > development in Eclipse. If a project is a must for Eclipse Java Model,
> it
> > > means I have to create a fake project that is hidden from the user.
> Right?
> > > Thanks again.
> > >
> > > Vladimir
> > > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > > news:bodsf7$c14$1@eclipse.org...
> > > > Assumning your external jar is in 'd:\libs\mylib.jar' and your
project
> > is
> > > > 'P' and the external jar is on P's classpath:
> > > > IProject project =
> > > ResourcesPlugin.getWorkspace().getRoot().getProject("P");
> > > > IJavaProject javaProject = JavaCore.create(project);
> > > > IPackageFragmentRoot root =
> > > > javaProject.getPackageFragmentRoot("d:\libs\mylib.jar");
> > > > IPackageFragment pkg = root.getPackageFragment("your.package");
> > > > IClassFile classFile = pkg.getClassFile("X.class");
> > > >
> > > > Jerome
> > > >
> > > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > > news:bodrvr$bcn$1@eclipse.org...
> > > > > Hello,
> > > > >
> > > > > I am looking for any suggestions about creating a IJavaElement for
a
> > > class
> > > > > that resides in an external jar. Do I need to go through creating
> > > > IRecource
> > > > > for a jar, and then user JavaCore.create(IResource)? Then get
> > > IJavaElement
> > > > > out of the result? Is the IProject required for any of this?
> > > > >
> > > > > I would greatly appreciate any pointers. Thanks.
> > > > >
> > > > > Vladimir
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: To create a IJavaElement out of a class in a jar? [message #114677 is a reply to message #114664] |
Fri, 07 November 2003 08:50   |
Eclipse User |
|
|
|
Originally posted by: vgusev.graphlogic.com
Jerome, It really doesn't matter what JDO is in this context. Let's rephrase
it:
The questions I am going to ask are what is the TypeHierarchy of this
class - I want to pass this java element to the TypeHierarchyViewer. My
class instance instantiated in memory and is described in
a local jar - I need to present its relationships exactly as in the java IDE
type
browser. Please confirm that for this scenario I have to have a fake
project (I hate the idea to have it). Thanks again.
Vladimir
"Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
news:bofukv$cp2$1@eclipse.org...
> Sorry I don't know what the JDO persitence store is, so I cannot help you
> here.
>
> Jerome
>
> "Vladimir" <vgusev@graphlogic.com> wrote in message
> news:boe26f$iio$1@eclipse.org...
> > The questions I am going to ask are what is the TypeHierarchy of this
> > class - I want to pass this java element to the TypeHierarchyViewer. My
> > class instance is loaded from the JDO persistence store, it is described
> in
> > a local jar - I need to present its relationships exactly as in the type
> > browser. Please confirm that for this scenario I have to have a fake
> project
> > (I hate the idea to have it). Thanks again.
> >
> > Vladimir
> > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > news:bodvif$ftl$1@eclipse.org...
> > > If all you wanted is get the IClassFile handle, the code below would
> work
> > > without the project existing.
> > > But I assume that your going to ask questions to this handle. If the
> > project
> > > doesn't exist, those will throw a JavaModelException.
> > > So yes, you need to create a fake Java project and add your external
jar
> > to
> > > its classpath before you can use the IClassFile handle.
> > >
> > > Jerome
> > >
> > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > news:bodtcj$d4s$1@eclipse.org...
> > > > Jerome,
> > > >
> > > > Thanks for a swift response! Does it mean that I _must_ have a
project
> > > > present? I am trying to do this for a class that is not related to a
> > java
> > > > project per se - in an application that has nothing to do with java
> > > > development in Eclipse. If a project is a must for Eclipse Java
Model,
> > it
> > > > means I have to create a fake project that is hidden from the user.
> > Right?
> > > > Thanks again.
> > > >
> > > > Vladimir
> > > > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > > > news:bodsf7$c14$1@eclipse.org...
> > > > > Assumning your external jar is in 'd:\libs\mylib.jar' and your
> project
> > > is
> > > > > 'P' and the external jar is on P's classpath:
> > > > > IProject project =
> > > > ResourcesPlugin.getWorkspace().getRoot().getProject("P");
> > > > > IJavaProject javaProject = JavaCore.create(project);
> > > > > IPackageFragmentRoot root =
> > > > > javaProject.getPackageFragmentRoot("d:\libs\mylib.jar");
> > > > > IPackageFragment pkg = root.getPackageFragment("your.package");
> > > > > IClassFile classFile = pkg.getClassFile("X.class");
> > > > >
> > > > > Jerome
> > > > >
> > > > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > > > news:bodrvr$bcn$1@eclipse.org...
> > > > > > Hello,
> > > > > >
> > > > > > I am looking for any suggestions about creating a IJavaElement
for
> a
> > > > class
> > > > > > that resides in an external jar. Do I need to go through
creating
> > > > > IRecource
> > > > > > for a jar, and then user JavaCore.create(IResource)? Then get
> > > > IJavaElement
> > > > > > out of the result? Is the IProject required for any of this?
> > > > > >
> > > > > > I would greatly appreciate any pointers. Thanks.
> > > > > >
> > > > > > Vladimir
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: To create a IJavaElement out of a class in a jar? [message #114742 is a reply to message #114677] |
Fri, 07 November 2003 10:22   |
Eclipse User |
|
|
|
To create an ITypeHierarchy, the element has to exist (in the Java model
sense). So the IClassFile has to be on the classpath of a Java project. So
yes you will have to create a project if you want to open a type hierarchy.
Jerome
"Vladimir" <vgusev@graphlogic.com> wrote in message
news:bog7sh$o8s$1@eclipse.org...
> Jerome, It really doesn't matter what JDO is in this context. Let's
rephrase
> it:
>
> The questions I am going to ask are what is the TypeHierarchy of this
> class - I want to pass this java element to the TypeHierarchyViewer. My
> class instance instantiated in memory and is described in
> a local jar - I need to present its relationships exactly as in the java
IDE
> type
> browser. Please confirm that for this scenario I have to have a fake
> project (I hate the idea to have it). Thanks again.
>
> Vladimir
>
> "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> news:bofukv$cp2$1@eclipse.org...
> > Sorry I don't know what the JDO persitence store is, so I cannot help
you
> > here.
> >
> > Jerome
> >
> > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > news:boe26f$iio$1@eclipse.org...
> > > The questions I am going to ask are what is the TypeHierarchy of this
> > > class - I want to pass this java element to the TypeHierarchyViewer.
My
> > > class instance is loaded from the JDO persistence store, it is
described
> > in
> > > a local jar - I need to present its relationships exactly as in the
type
> > > browser. Please confirm that for this scenario I have to have a fake
> > project
> > > (I hate the idea to have it). Thanks again.
> > >
> > > Vladimir
> > > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > > news:bodvif$ftl$1@eclipse.org...
> > > > If all you wanted is get the IClassFile handle, the code below would
> > work
> > > > without the project existing.
> > > > But I assume that your going to ask questions to this handle. If the
> > > project
> > > > doesn't exist, those will throw a JavaModelException.
> > > > So yes, you need to create a fake Java project and add your external
> jar
> > > to
> > > > its classpath before you can use the IClassFile handle.
> > > >
> > > > Jerome
> > > >
> > > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > > news:bodtcj$d4s$1@eclipse.org...
> > > > > Jerome,
> > > > >
> > > > > Thanks for a swift response! Does it mean that I _must_ have a
> project
> > > > > present? I am trying to do this for a class that is not related to
a
> > > java
> > > > > project per se - in an application that has nothing to do with
java
> > > > > development in Eclipse. If a project is a must for Eclipse Java
> Model,
> > > it
> > > > > means I have to create a fake project that is hidden from the
user.
> > > Right?
> > > > > Thanks again.
> > > > >
> > > > > Vladimir
> > > > > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > > > > news:bodsf7$c14$1@eclipse.org...
> > > > > > Assumning your external jar is in 'd:\libs\mylib.jar' and your
> > project
> > > > is
> > > > > > 'P' and the external jar is on P's classpath:
> > > > > > IProject project =
> > > > > ResourcesPlugin.getWorkspace().getRoot().getProject("P");
> > > > > > IJavaProject javaProject = JavaCore.create(project);
> > > > > > IPackageFragmentRoot root =
> > > > > > javaProject.getPackageFragmentRoot("d:\libs\mylib.jar");
> > > > > > IPackageFragment pkg = root.getPackageFragment("your.package");
> > > > > > IClassFile classFile = pkg.getClassFile("X.class");
> > > > > >
> > > > > > Jerome
> > > > > >
> > > > > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > > > > news:bodrvr$bcn$1@eclipse.org...
> > > > > > > Hello,
> > > > > > >
> > > > > > > I am looking for any suggestions about creating a IJavaElement
> for
> > a
> > > > > class
> > > > > > > that resides in an external jar. Do I need to go through
> creating
> > > > > > IRecource
> > > > > > > for a jar, and then user JavaCore.create(IResource)? Then get
> > > > > IJavaElement
> > > > > > > out of the result? Is the IProject required for any of this?
> > > > > > >
> > > > > > > I would greatly appreciate any pointers. Thanks.
> > > > > > >
> > > > > > > Vladimir
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: To create a IJavaElement out of a class in a jar? [message #114755 is a reply to message #114742] |
Fri, 07 November 2003 11:04   |
Eclipse User |
|
|
|
Originally posted by: vgusev.graphlogic.com
Thanks, that wraps it.
"Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
news:bogd8r$vd4$1@eclipse.org...
> To create an ITypeHierarchy, the element has to exist (in the Java model
> sense). So the IClassFile has to be on the classpath of a Java project. So
> yes you will have to create a project if you want to open a type
hierarchy.
>
> Jerome
>
> "Vladimir" <vgusev@graphlogic.com> wrote in message
> news:bog7sh$o8s$1@eclipse.org...
> > Jerome, It really doesn't matter what JDO is in this context. Let's
> rephrase
> > it:
> >
> > The questions I am going to ask are what is the TypeHierarchy of this
> > class - I want to pass this java element to the TypeHierarchyViewer. My
> > class instance instantiated in memory and is described in
> > a local jar - I need to present its relationships exactly as in the java
> IDE
> > type
> > browser. Please confirm that for this scenario I have to have a fake
> > project (I hate the idea to have it). Thanks again.
> >
> > Vladimir
> >
> > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > news:bofukv$cp2$1@eclipse.org...
> > > Sorry I don't know what the JDO persitence store is, so I cannot help
> you
> > > here.
> > >
> > > Jerome
> > >
> > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > news:boe26f$iio$1@eclipse.org...
> > > > The questions I am going to ask are what is the TypeHierarchy of
this
> > > > class - I want to pass this java element to the TypeHierarchyViewer.
> My
> > > > class instance is loaded from the JDO persistence store, it is
> described
> > > in
> > > > a local jar - I need to present its relationships exactly as in the
> type
> > > > browser. Please confirm that for this scenario I have to have a fake
> > > project
> > > > (I hate the idea to have it). Thanks again.
> > > >
> > > > Vladimir
> > > > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > > > news:bodvif$ftl$1@eclipse.org...
> > > > > If all you wanted is get the IClassFile handle, the code below
would
> > > work
> > > > > without the project existing.
> > > > > But I assume that your going to ask questions to this handle. If
the
> > > > project
> > > > > doesn't exist, those will throw a JavaModelException.
> > > > > So yes, you need to create a fake Java project and add your
external
> > jar
> > > > to
> > > > > its classpath before you can use the IClassFile handle.
> > > > >
> > > > > Jerome
> > > > >
> > > > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > > > news:bodtcj$d4s$1@eclipse.org...
> > > > > > Jerome,
> > > > > >
> > > > > > Thanks for a swift response! Does it mean that I _must_ have a
> > project
> > > > > > present? I am trying to do this for a class that is not related
to
> a
> > > > java
> > > > > > project per se - in an application that has nothing to do with
> java
> > > > > > development in Eclipse. If a project is a must for Eclipse Java
> > Model,
> > > > it
> > > > > > means I have to create a fake project that is hidden from the
> user.
> > > > Right?
> > > > > > Thanks again.
> > > > > >
> > > > > > Vladimir
> > > > > > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > > > > > news:bodsf7$c14$1@eclipse.org...
> > > > > > > Assumning your external jar is in 'd:\libs\mylib.jar' and your
> > > project
> > > > > is
> > > > > > > 'P' and the external jar is on P's classpath:
> > > > > > > IProject project =
> > > > > > ResourcesPlugin.getWorkspace().getRoot().getProject("P");
> > > > > > > IJavaProject javaProject = JavaCore.create(project);
> > > > > > > IPackageFragmentRoot root =
> > > > > > > javaProject.getPackageFragmentRoot("d:\libs\mylib.jar");
> > > > > > > IPackageFragment pkg =
root.getPackageFragment("your.package");
> > > > > > > IClassFile classFile = pkg.getClassFile("X.class");
> > > > > > >
> > > > > > > Jerome
> > > > > > >
> > > > > > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > > > > > news:bodrvr$bcn$1@eclipse.org...
> > > > > > > > Hello,
> > > > > > > >
> > > > > > > > I am looking for any suggestions about creating a
IJavaElement
> > for
> > > a
> > > > > > class
> > > > > > > > that resides in an external jar. Do I need to go through
> > creating
> > > > > > > IRecource
> > > > > > > > for a jar, and then user JavaCore.create(IResource)? Then
get
> > > > > > IJavaElement
> > > > > > > > out of the result? Is the IProject required for any of this?
> > > > > > > >
> > > > > > > > I would greatly appreciate any pointers. Thanks.
> > > > > > > >
> > > > > > > > Vladimir
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: To create a IJavaElement out of a class in a jar? [message #115472 is a reply to message #114742] |
Mon, 10 November 2003 22:16   |
Eclipse User |
|
|
|
Originally posted by: vgusev.graphlogic.com
Jerome,
Thanks to your help I am able to do most of what I wanted. However, I have
ran into two problems: 1. When TypeHierarchy view opens for a IType an
attempt is made automatically to also open a class file editor - my end user
is not supposed to see it, but I don't know how to prevent it from opening.
2. The hierarchy view does not show the hiearchy - it only shows the class
itself. Does it mean that the external jar file which contains the class in
question does not have all necessary info?
Thanks.
Vladimir
"Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
news:bogd8r$vd4$1@eclipse.org...
> To create an ITypeHierarchy, the element has to exist (in the Java model
> sense). So the IClassFile has to be on the classpath of a Java project. So
> yes you will have to create a project if you want to open a type
hierarchy.
>
> Jerome
>
> "Vladimir" <vgusev@graphlogic.com> wrote in message
> news:bog7sh$o8s$1@eclipse.org...
> > Jerome, It really doesn't matter what JDO is in this context. Let's
> rephrase
> > it:
> >
> > The questions I am going to ask are what is the TypeHierarchy of this
> > class - I want to pass this java element to the TypeHierarchyViewer. My
> > class instance instantiated in memory and is described in
> > a local jar - I need to present its relationships exactly as in the java
> IDE
> > type
> > browser. Please confirm that for this scenario I have to have a fake
> > project (I hate the idea to have it). Thanks again.
> >
> > Vladimir
> >
> > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > news:bofukv$cp2$1@eclipse.org...
> > > Sorry I don't know what the JDO persitence store is, so I cannot help
> you
> > > here.
> > >
> > > Jerome
> > >
> > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > news:boe26f$iio$1@eclipse.org...
> > > > The questions I am going to ask are what is the TypeHierarchy of
this
> > > > class - I want to pass this java element to the TypeHierarchyViewer.
> My
> > > > class instance is loaded from the JDO persistence store, it is
> described
> > > in
> > > > a local jar - I need to present its relationships exactly as in the
> type
> > > > browser. Please confirm that for this scenario I have to have a fake
> > > project
> > > > (I hate the idea to have it). Thanks again.
> > > >
> > > > Vladimir
> > > > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > > > news:bodvif$ftl$1@eclipse.org...
> > > > > If all you wanted is get the IClassFile handle, the code below
would
> > > work
> > > > > without the project existing.
> > > > > But I assume that your going to ask questions to this handle. If
the
> > > > project
> > > > > doesn't exist, those will throw a JavaModelException.
> > > > > So yes, you need to create a fake Java project and add your
external
> > jar
> > > > to
> > > > > its classpath before you can use the IClassFile handle.
> > > > >
> > > > > Jerome
> > > > >
> > > > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > > > news:bodtcj$d4s$1@eclipse.org...
> > > > > > Jerome,
> > > > > >
> > > > > > Thanks for a swift response! Does it mean that I _must_ have a
> > project
> > > > > > present? I am trying to do this for a class that is not related
to
> a
> > > > java
> > > > > > project per se - in an application that has nothing to do with
> java
> > > > > > development in Eclipse. If a project is a must for Eclipse Java
> > Model,
> > > > it
> > > > > > means I have to create a fake project that is hidden from the
> user.
> > > > Right?
> > > > > > Thanks again.
> > > > > >
> > > > > > Vladimir
> > > > > > "Jerome Lanneluc" <jerome_lanneluc@fr.ibm.com> wrote in message
> > > > > > news:bodsf7$c14$1@eclipse.org...
> > > > > > > Assumning your external jar is in 'd:\libs\mylib.jar' and your
> > > project
> > > > > is
> > > > > > > 'P' and the external jar is on P's classpath:
> > > > > > > IProject project =
> > > > > > ResourcesPlugin.getWorkspace().getRoot().getProject("P");
> > > > > > > IJavaProject javaProject = JavaCore.create(project);
> > > > > > > IPackageFragmentRoot root =
> > > > > > > javaProject.getPackageFragmentRoot("d:\libs\mylib.jar");
> > > > > > > IPackageFragment pkg =
root.getPackageFragment("your.package");
> > > > > > > IClassFile classFile = pkg.getClassFile("X.class");
> > > > > > >
> > > > > > > Jerome
> > > > > > >
> > > > > > > "Vladimir" <vgusev@graphlogic.com> wrote in message
> > > > > > > news:bodrvr$bcn$1@eclipse.org...
> > > > > > > > Hello,
> > > > > > > >
> > > > > > > > I am looking for any suggestions about creating a
IJavaElement
> > for
> > > a
> > > > > > class
> > > > > > > > that resides in an external jar. Do I need to go through
> > creating
> > > > > > > IRecource
> > > > > > > > for a jar, and then user JavaCore.create(IResource)? Then
get
> > > > > > IJavaElement
> > > > > > > > out of the result? Is the IProject required for any of this?
> > > > > > > >
> > > > > > > > I would greatly appreciate any pointers. Thanks.
> > > > > > > >
> > > > > > > > Vladimir
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: To create a IJavaElement out of a class in a jar? [message #116000 is a reply to message #115472] |
Wed, 12 November 2003 04:13  |
Eclipse User |
|
|
|
"Vladimir" <vgusev@graphlogic.com> wrote in message
news:bopk86$aem$1@eclipse.org...
> 1. When TypeHierarchy view opens for a IType an
> attempt is made automatically to also open a class file editor - my end
user
> is not supposed to see it, but I don't know how to prevent it from
opening.
Sorry I don't know how the TypeHierarchy view itself works. You might want
to repost your question with a specific subject.
> 2. The hierarchy view does not show the hiearchy - it only shows the class
> itself. Does it mean that the external jar file which contains the class
in
> question does not have all necessary info?
It means that the super and subtypes could not be resolved. This is often
due to a classpath problem. In your case, did you add the JRE library (i.e.
rt.jar) on your fake project's classpath?
|
|
|
Goto Forum:
Current Time: Tue Sep 16 10:02:59 EDT 2025
Powered by FUDForum. Page generated in 0.06841 seconds
|