Hi, I have a resonable knowledge of actually programming Java, but I cannot grasp how to get packages working. I understand how to declare that something is part of a package in the code, and that the package hierarchy is produced using directory structure on the hard-drive - but I have no idea where to put this directory structure, and how to make my Java programmes find the package!? E.g if I store a package in d:\MyPackages\PackageOne, how does the compiler find it? thanks, Ben
you should compile the files in the package from the directory where the package is stored. To compile Packages on my (linux)pc i would use peter@linux:~ >javac MyPackages/PackageOne/Class1.java where "peter@linux:~ >" is the prompt. I also run my applications from the same prompt. I'm not totally sure that windows follows the same rules but it should be similar. HTH
Pete<br />"Reality is an illusion <br />brought on by a lack of <br />drink, drugs and smut"
Originally posted by Ben Wood: but I have no idea where to put this directory structure,
Anywhere you'd like that you can tell the compiler and the JRE (JVM) to find the files.
and how to make my Java programmes find the package!?
with your import statement(s)
E.g if I store a package in d:\MyPackages\PackageOne, how does the compiler find it?
You'll usually let the compiler know the location of relevant packages and classes with the import statements in the class definition. In one of the above links you'll also find information on setting the classpath for the compiler. The JRE (JVM) will need to also be able to find the necessary classes and packages, in which case you might need to set the classpath accordingly. Some information on doing this is referenced above, and a quick search on this forum is sure to turn up more information. (Note: the search page link is at the top right of this page.) Good Luck.