[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re: class file there but Eclipse misses it, errantly says "build path is incomplete.

Richard schreef:
Eric Rizzo wrote:

Richard wrote:

The GUI has about 85 frames (windows), each as its own (sub)class in its own file, and every one of them calls the API. Yet ONE line in ONE particular frame is having trouble doing what all the others do. Eclipse gives two errors:


The project was not built since its build path is incomplete. Cannot find the class file for <api.package>.<api_class>$<sub_class>. Fix the build...

and

The type <api.package>.<api_class>$<sub_class> cannot be resolved. It is ..

My FIRST reaction was - hey, problem with what I was given! So, I did a simple one-line javac compile and proved that the results _exactly_ match what I was given from the people I borrowed the code from, to the byte (sha1sum is your friend).

Well, when I look in the directory where the API class sits (it's not in a jar), the supposedly missing class file is staring me in the face.

Have you imported everything into a single Eclipse project, or multiple projects?
Is the directory that contains the .class files included in the project's Build Path? And are the .class files in a proper directory structure that matches their packages?


Without an exact picture of how the project is laid out it is hard to do more than guess at this point.

Eric

Hi Eric,

I imported only the GUI, as a single project. I left the API as a library to call. It's configured in using Project -> Properties -> Java Build Path -> Libraries -> Add External Class Folder. Then, I moved it to the top under Order and Export (I take it that the check-box means to include during export).

The directory that contains the API's class files is included implicitly, but not explicitly: It's part of a "package", and there's a directory tree that reflects that hierarchy - the configured dir is the parent of the hierarchy.

This smells funny.
Suppose the project is âGUI testâ and is set up to have source files in src/ and class files in bin/.
If your class is in package com.my.company.GUI it has to be in directory src/com/my/company/GUI.


This means that when youâre importing, you do NOT choose the directory GUI as source, but rather the directory that contains com/, and check com.

Example: you have received a zip with the code, and unzip it in GUI-to-test. The code has a proper Java directory structure, so you will have
GUI-to-test/com/my/company/package-doing-computation
GUI-to-test/com/my/company/utility-package
GUI-to-test/com/my/company/GUI


You have two options: either you create an empty project and import everything it, or you create a project based on existing files.

The latter goes like this:
File â New â Project â Java Project â Create project from existing source. Here you browse to directory GUI-to-test. The wizard will automatically choose all code, so youâll want to remove the non-GUI code from the build path. It will, however, import these directories in the project, so you might not want that. So on to the second option:


Create an empty project with New â Project â Java project.
File â Importâ â General â File System â From Directory should be GUI-to-test, you unfold com/my/company and check the box at GUI, but not at the other ones. The destination should be your new project (or rather, its source folder). Unfortunately, this will copy the all files. You can also directly import from an archive file (the ZIP).


If this doesnât fit you, describe *exactly* what you did and what you want.

HTH, H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html