java - Eclipse: Getting error when adding external class / jar files to build path: "XYZ Cannot be resolved to a type" -
i working java , eclipse, both bit out of comfort zone (yup , assignment...).
i have 2 class files need use in project. far have tried:
attempt #1
i tried adding external class folder:
- in project folder have added
classes\legacyfolder. - in
properties > java build path > librariesclicked onadd external class folder - in window opened selected
classesfolder created in step 1. - in code have added
import legacy.*;
result:
can use classes in class files getting following errors:
(seems occur when classes attempting use 1 another)
the project not built since build path incomplete. cannot find class file ishkesher. fix build path try building project
the type ishkesher cannot resolved. indirectly referenced required .class files
note: tried class folder - same results.

attempt #2
someone suggested using jar files should easier, gave try:
- created
jarfile containingclassfiles:jar cvf classes.jar contactslist.class ishkesher.class - added
jarfile build path using this tutorial.
result:
getting error each usage of classes in jar file:
xyz cannot resolved type

any ideas how make class files available in code?
edit:
turned out attempt #2 worked once using source files in default package (cannot figure out why though...).
try instructions.
if don't want include copy of borat.jar, want reference external folder, 1 step -
no copy step -
your java project > right click > build path > configure build path > add external jars button > select jar > ok. if want jar become part of java app, ie create copy of jar in java app, use steps below.
step 1- create lib folder in app store jars
your java project > right click > new folder > folder name = lib step 2 - import copies of necessary jars lib folder
your java project > lib folder > right click > import > general --> file system > directory = directory stored jar files. > ...you should see jars in folder. lets want import borat.jar > finish. step 3 - check if step 2 done correctly
your java project > lib folder > expand lib folder see contents. borat.jar should listed there. nice ! step 4 - finally, add jars project
your java project > lib folder > right click > build path > configure build path > add jars button > expand project > expand lib folder > select borat.jar > ok.
Comments
Post a Comment