I am working with Java and Eclipse, which are both a bit out of my comfort zone (yup , this is an assignment...).
I have 2 class
files which I need to use in my project. So far I have tried:
Attempt #1
I tried adding an external class folder
:
- In my project folder I have added
classes\legacy
folder. - In
Properties > Java Build Path > Libraries
I Clicked on theAdd External Class Folder
- In the window that opened I selected the
classes
folder created in step 1. - In my code I have added
import legacy.*;
Result:
I can use the classes in the class
files but getting the following errors:
(seems to occur when the classes are attempting to use one another)
The project was not built since its build path is incomplete. Cannot find the class file for IshKesher. Fix the build path then try building this project
The type IshKesher cannot be resolved. It is indirectly referenced from required .class files
Note: tried for class folder
as well - same results.
Attempt #2
Someone suggested that using jar files should be easier, so I gave it a try:
- Created a
jar
file containing theclass
files:jar cvf classes.jar ContactsList.class IshKesher.class
- Added the
jar
file to the build path using this tutorial.
Result:
Getting an error for each usage of classes in the jar file:
XYZ Cannot be resolved to a type
Any Ideas how make the class files available in my code?
EDIT:
It turned out that Attempt #2
worked once using my source files in the default package
(cannot figure out why though...).