1

What is the difference between internal and external libraries in Java?

For example,

   import java.util.*;
   import java.io.File;

Is java.util and/or java.io an internal library, external library, or something else? Thanks!

Laura_E
  • 169
  • 1
  • 10
  • 2
    Internal libraries are the ones that are provided by Sun/Oracle and shipped as part of JDK. External libraries are from third parties provided as a JAR, which you would add to class path to access the resources. Example: Apache Logging library - log4j.jar – JavaHopper Aug 04 '16 at 22:03
  • It is not libraries but packages. It allows you to write your code using simple class names like `ArrayList` but at the same time it lets compiler compile such names with their full names like `java.util.ArrayList`. Generally it is better to avoid `.*` (more info: [Why is using a wild card with a Java import statement bad?](https://stackoverflow.com/questions/147454/why-is-using-a-wild-card-with-a-java-import-statement-bad)). – Pshemo Aug 04 '16 at 22:05
  • All imports that start with java are from jdk so they are internal – Mr.Q Aug 04 '16 at 22:09
  • Anyway your question is unclear. Your title is about internal/external libraries but post is about importing package where both imports are using standard Java packages/classes. Can you clarify your question more? – Pshemo Aug 04 '16 at 22:11
  • @Pshemo I confused packages with libraries. So java.util and java.io are packages and have nothing to do with internal/external libraries... my mistake! – Laura_E Aug 05 '16 at 15:33
  • Libraries (in sense of JAR files) can contain many packages which in turn can contain many`.class` files. So they are related but are not the same. Consider using [edit] option to clarify your question. For now it is still unclear what you are asking about. – Pshemo Aug 05 '16 at 15:42

1 Answers1

3

Conceptually, an internal library is either "a library that is provided as (effectively) "part of the language itself," or "a library that is known only to your (big) project." In one case, only the language-vendor has control of it. In the other, only you do.

An external library is something that comes from an outside source. (Hence, neither you nor the language-vendor "owns" it.) Your project references it, and depends on (a certain version of) it such that "it cannot live without it," but it is not "(just) a part of this project."

Mike Robinson
  • 8,490
  • 5
  • 28
  • 41