Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bypassing the classpath

 
Dan Maples
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I have written a myUtilities.java program to make things easyer when I write other programs. The problem I am having is when I use it in other programs and go to compile the other programs I end up having to type in 10 or so different classpaths to get it to compile properly. Is there something I can do to the myUtilities.java program that will make it so that I don't have to type in 10 classpaths when compileing the other programs. I have heard of packages, but I don't know much about them and if they will help or not in my case. Thanks in advance-Dan
 
Jon Entwistle
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dan,

Packages are ways of logicaly grouping your source files and should be used for all applications which you write.

For writing your own reusable classes this is important - by writing your classes in a package (say myPackage), compiling them and puting the compiled files on your classpath, you can reuse your classes with:

import myPackage.*; // * imports all files in the package myPackage

Do a quick search on google for a java package tutorial and you will soon be up to speed.

Regards,

Jon
 
Dan Maples
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Jon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic