Rajaut Baptiste Rajaut Baptiste - 1 year ago 92
Java Question

(Solved)IntellIJ idea does not want to use my external library

Solved by adding a package to my library, which used a default package.

I have a school project to build a Jar library containing a basic card management system, then use it in the main project (a blackjack game)

With IDEA I separated the modules, then I built the jar artifact. I now have all my classes in my


The generic card management module name is named
(card in french), generated into a

Now I add this jar as a library for the

I did an
import Carte.*;
which give me
unresolved symbol Carte

Without import, I got unresolved symbol for classes from my library

How am i supposed to use my library?

enter image description here
enter image description here

Answer Source

It looks like the classes in your library are in the default package, i.e. they don't have a specified package name. Carte is the name of the module, but not a Java package. I marked what I mean on this screenshot.

Java doesn't allow importing classes from the default package, as per Java language specification:

It is a compile time error to import a type from the unnamed package.

So, you should avoid the default package to be able to use the classes from a library.

Another possible reason of why the classes seem to be in the default package is that you've improperly packed the jar.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download