Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between package and project in Eclipse?

Tags:

eclipse

I don't really understand what the point of having a package is. Every Class is kept in a different file, so what's the point of using different packages in a single project?

like image 705
K.Patel Avatar asked Jan 04 '23 01:01

K.Patel


1 Answers

An Eclipse project has nothing to do with Java. It is a feature of Eclipse to organize and configure your different projects.

A Java package is a language feature of Java. You can use them to structure your project and control visibility between different classes. This becomes necessary even in relatively small projects, which already might have a few hundred classes. I suggest you look for a basic tutorial on what a Java package is and what it can do. To give you a headstart, here is what the official documentation has to say about the purpose of bundling related classes in a package:

You should bundle these classes and the interface in a package for several reasons, including the following:

  • You and other programmers can easily determine that these types are related.
  • You and other programmers know where to find types that can provide graphics-related functions.
  • The names of your types won't conflict with the type names in other packages because the package creates a new namespace.
  • You can allow types within the package to have unrestricted access to one another yet still restrict access for types outside the package.
like image 161
André Stannek Avatar answered Jan 06 '23 14:01

André Stannek