Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Newbie question: using existing classes
Newbie question: using existing classes [message #87079] Wed, 20 August 2003 08:20 Go to next message
Eclipse UserFriend
Originally posted by: crabtree8.xs4all.nl

Hi group,

I have a java sourcefile that uses (imports) a couple of class files. I've
created a new project in Eclipse and imported the sourcefile and copied
the class files, but the import statement that refers to the class library
generates an error: 'the import xxx cannot be resolved.'
I can't get this to work. I tried to add a classpath variable, it did not
work. The class files are there, in the subfolder, why would there be a
problem?
I compiled and ran the java file from the command line and in the Netbeans
IDE, and everything worked fine. I guess I am overlooking something very
simple.
I really would appreciate an answer... I am getting somewhat frustrates :(

TIA, Mark.
Re: Newbie question: using existing classes [message #87095 is a reply to message #87079] Wed, 20 August 2003 08:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam_kiezun.ch.ibm.remove.com

> I have a java sourcefile that uses (imports) a couple of class files. I've
> created a new project in Eclipse and imported the sourcefile and copied
> the class files, but the import statement that refers to the class library
> generates an error: 'the import xxx cannot be resolved.'

where did you copy the class files?
you should copy them to a new folder, and then add that to the project's classpath
(project > properties > java build path > libraries > add class folder)

a.
--
eclipse.org
Re: Newbie question: using existing classes [message #87110 is a reply to message #87095] Wed, 20 August 2003 08:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: crabtree8.xs4all.nl

Adam Kiezun wrote:

> > I have a java sourcefile that uses (imports) a couple of class files. I've
> > created a new project in Eclipse and imported the sourcefile and copied
> > the class files, but the import statement that refers to the class library
> > generates an error: 'the import xxx cannot be resolved.'

> where did you copy the class files?
> you should copy them to a new folder, and then add that to the project's
classpath
> (project > properties > java build path > libraries > add class folder)

> a.
> --
> eclipse.org

Sorry, forgot to mention it, I have tried this. But then I get an error
'cannot nest 'test/xxx' in test', where 'test' is the project folder and
'xxx' is the new folder with the class files.

Mark.
Re: Newbie question: using existing classes [message #87125 is a reply to message #87110] Wed, 20 August 2003 08:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam_kiezun.ch.ibm.remove.com

> Sorry, forgot to mention it, I have tried this. But then I get an error
> 'cannot nest 'test/xxx' in test', where 'test' is the project folder and
> 'xxx' is the new folder with the class files.

but what does the rest of the message say, ha? :-)
'to enable the nesting exlude 'xxx' from from 'test''

to do that, go to the 'Source' tab, expand the project node, double click on 'Exclusion filter' and add the 'xxx' folder

hth
a.
--
eclipse.org
Re: Newbie question: using existing classes [message #87171 is a reply to message #87125] Wed, 20 August 2003 09:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: crabtree8.xs4all.nl

Adam Kiezun wrote:

> > Sorry, forgot to mention it, I have tried this. But then I get an error
> > 'cannot nest 'test/xxx' in test', where 'test' is the project folder and
> > 'xxx' is the new folder with the class files.

> but what does the rest of the message say, ha? :-)
> 'to enable the nesting exlude 'xxx' from from 'test''

> to do that, go to the 'Source' tab, expand the project node, double click on
'Exclusion filter' and add the 'xxx' folder

> hth
> a.
> --
> eclipse.org

Hi Adam,

Thanks, I did that, but now my project could not be built because the
build path is incomplete?
I deleted the project, created a new one and imported all the files. I
didn't add a class folder to the build path. Now... I don't get the
original problem again ('import xxx cannot be resolved'), now it's 'the
import xxx is never used'. And a declaration of an instance of a class in
the class folder gives 'myclass can not be resolved (or is not a valid
type) for the field myvar'
Then if I add a class folder and enable the nesting, again I get an error
'The import xxx cannot be resolved'

Mark.
Re: Newbie question: using existing classes [message #87191 is a reply to message #87171] Wed, 20 August 2003 10:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam_kiezun.ch.ibm.remove.com

try this:
create a new project 'test'
create a source folder 'src' in 'test'
create a folder 'xxx' in 'test'
put the 'xxx' folder on the classpath as a class folder (no exclusion should be necessary now)
copy your classfiles to xxx
copy your sources to src

btw. i understand that the classfiles are some precompiled classfiles you're only referencing, not the classfiles for your own
sources from 'src'

a.
--
eclipse.org
Re: Newbie question: using existing classes [message #87245 is a reply to message #87191] Wed, 20 August 2003 11:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: crabtree8.xs4all.nl

Adam Kiezun wrote:

> try this:
> create a new project 'test'
> create a source folder 'src' in 'test'
> create a folder 'xxx' in 'test'
> put the 'xxx' folder on the classpath as a class folder (no exclusion should
be necessary now)
> copy your classfiles to xxx
> copy your sources to src

> btw. i understand that the classfiles are some precompiled classfiles you're
only referencing, not the classfiles for your own
> sources from 'src'

> a.
> --
> eclipse.org

Ok, I did this. Now the source file and the class files show up in the
package explorer. Yes, the classfiles are precompiled, they are not my
own. They are from the anfy3dAPI, a 3d graphics library.
Now my project can't be built: 'The project was not built since its build
path is incomplete. Cannot find the class file for a3dAPI.anfy3dAPI...' I
put the class files in a class folder named 'a3dAPI', the same folder name
as in the zip file they came in. I also tried a class folder named 'xxx',
same result. I don't know if this is an error in the build path or has
something to do with the class files?
Anyway, since I am not sure what I'm doing maybe I'd better go back to the
Netbeans IDE...
Thanks for you help!

greetings, Mark.
Re: Newbie question: using existing classes [message #87259 is a reply to message #87245] Wed, 20 August 2003 11:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam_kiezun.ch.ibm.remove.com

> I put the class files in a class folder named 'a3dAPI', the same folder name
> as in the zip file they came in.

just curious: why can't you simply put the zip file on the classpath?

a.
--
eclipse.org
Re: Newbie question: using existing classes [message #87274 is a reply to message #87245] Wed, 20 August 2003 12:18 Go to previous messageGo to next message
Eclipse UserFriend
> Ok, I did this. Now the source file and the class files show up in the
> package explorer. Yes, the classfiles are precompiled, they are not my
> own. They are from the anfy3dAPI, a 3d graphics library.
> Now my project can't be built: 'The project was not built since its build
> path is incomplete. Cannot find the class file for a3dAPI.anfy3dAPI...' I
> put the class files in a class folder named 'a3dAPI', the same folder name
> as in the zip file they came in. I also tried a class folder named 'xxx',
You are doing something wrong than.;-).

> same result. I don't know if this is an error in the build path or has
> something to do with the class files?
Well if you have precompiled class files you should create a jar
and add this to your project. There is no fuzz about class files anymore
and it looks smoother anyway.

If you get crazy about class files you have to check which directory you
include.
You know in Java the package-hierarchy is represented by the directories.
Therefore you must never add a package directory to your classpath.

Example:

class org.eclipse.MyClass:
directory: Drive/eclipse/workspace/my.project/bin/org/eclipse/MyClass.c lass
If you want to add the class to it you have to add
Drive/eclipse/workspace/my.project/bin to your classpath. Therefore the
toplevel package must not show off in classpath.

If not you are running into serious problems.

> Anyway, since I am not sure what I'm doing maybe I'd better go back to the
> Netbeans IDE...
Well or check the help context and create the example project presented and
explained there. I learned the stuff by doing some experiments on the
presented steps.

> Thanks for you help!
Just hang in it for some more hours. Eclipse is great! Worth a couple of
hours of additional training ;)


Martin (Kersten)
Re: Newbie question: using existing classes [message #87422 is a reply to message #87274] Wed, 20 August 2003 17:24 Go to previous message
Eclipse UserFriend
Originally posted by: crabtree8.xs4all.nl

I experimented a bit with zipfiles and jar files but no success... I just
don't know enough about this to continue. I'm fed up with build paths an
project files now so i'll try something else :(


Thanks,

Mark.
Previous Topic:paths
Next Topic:Eclipse Ant support fails to expand properties with references
Goto Forum:
  


Current Time: Thu May 08 14:08:27 EDT 2025

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

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

Back to the top