Possible Duplicate:
Automatically load packages at startup
I have made two packages "Package1" and "Package2". Package2 calls Package1. it works fine.But everytime I am reopening Mathematica,I have to run both packages and then load them by Needs. I dont want to load packages again and again.
BeginPackagein Package2. This ensures that you only need to load Package2 manually before using it (and not Package1 as well). – Szabolcs Jul 24 '12 at 09:52Needs["Package1`"]in thePrivate`section of Package2 is the better method, for the sake of encapsulation and information hiding. – Leonid Shifrin Jul 24 '12 at 11:42Private`section for the import to be private, as it is theEndPackageof Package2 that removed the Package1 context from the context path. – Szabolcs Jul 24 '12 at 11:53BeginPackage-EndPackageandBegin-Enditself (which is a case sometimes), then you will create all its symbols in the public part of Package2 with such an import, and therefore, leak its details to the user. It is not a frequent case, but from the "black box" point of view importing into aPrivate`subsection adds extra protection. – Leonid Shifrin Jul 24 '12 at 12:11Begin["`Private`"]that makes the imported package private. – Szabolcs Jul 24 '12 at 17:37