Sehrish
Sehrish

Reputation: 13

Imported class files are shown under default package in Eclipse, how can i access them?

I am new in Java and Eclipse.

I am trying to import external class files in my code. I right click on project src->properties->buildpath->configure build path-> libraries->add external class folder by doing this default package appears in referenced libraries, having all the Java class files, but I still can't import my file.

Next I zip all .class files in a zip folder and add as external jars, by doing this all class files are shown under default package, under referenced libraries, and still I can't import my class files into code.

How can I rename the default package, so that I can access and import the class files?

By right clicking the classes, under the default package in the referenced libraries, there comes no option of refactor and move.

Upvotes: 1

Views: 2418

Answers (1)

charno
charno

Reputation: 474

You have to respect the File System Hierarchy in which the class files come from.

Let's assume that the class files (For example the class Clazz) have the declaration package ch.charno.xy, they must remain in a folder hierarchy ch/charno/xy/Clazz.class. You have to import the folder in which the subfolder ch resides so that the correct hierarchy is preserved. It's not possible to just import the class files, but you need to import the whole folder hierarchy.

(I hope I understood your question)

Upvotes: 1

Related Questions