Java Basics: Lesson 11, Java Packages and Imports (Live Video Education)
Lesson 11 in the Hugely Popular "Java Basics" Series by JDJ Editorial Board Member Yakov Fain
Apr. 13, 2005 12:00 AM
I've been using the Eclipse IDE for creating the Ping-Pong example, but you do not have to use any IDE, and can create these programs using any plain text editor and a standard javac compiler. In this case you'll need to follow the following steps to create these programs in the packages engine and screen.
- Create a directory PingPong
- Create two subdirectories inside called engine and package
- Type and save the file PingPongTable.java in the directory screens
- Type and save the file PingPongEngine in the directory engine
- Get into the PingPong directory and compile both classes:
- Now you can run the program as follows:
Please note that you have to use a dot as a separator (not a slash!) between the package and class names. Make sure that the system variable classpath includes the dot (see the very first lesson
of this series) to let JVM know that it has to look for classes starting from the current directory.
If you are starting a new project, you need to come up with the directory structures and the names for your packages and these are some considerations to keep in mind:
Reader Feedback: Page 1 of 1
Howard N-H commented on 13 Apr 2005
I'm glad you mentioned the use of interfaces as repositories of constants. While it may not be recommended in the strict sense of why interfaces exist, I've used this technique for years on large projects as a good way of organizing and reusing constants.
static imports commented on 12 Apr 2005
So you can use wildcards in the import? Can you use static import for static classes?
Java Basics series commented on 12 Apr 2005
Will the other 10 lessons be on SYS-CON.TV?
Java Live commented on 11 Apr 2005
Is it Yakov Fain who is speaking at the moment? A live Java lesson - cool!
sundeep commented on 11 Apr 2005
I used this lesson in conjunction with the last one, lesson ten on eclipse IDE and it really helped me
Subscribe to the World's Most Powerful Newsletters
Consumer-driven contracts are an essential part of a mature microservice testing portfolio enabling ...
Jun. 21, 2018 12:00 AM EDT Reads: 1,308
To Really Work for Enterprises, MultiCloud Adoption Requires Far Better and Inclusive Cloud Monitori...
Jun. 21, 2018 12:00 AM EDT Reads: 3,210
DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, ...
Jun. 20, 2018 11:15 PM EDT Reads: 8,066
Containers and Kubernetes allow for code portability across on-premise VMs, bare metal, or multiple ...
Jun. 20, 2018 11:00 PM EDT Reads: 2,486
We are seeing a major migration of enterprises applications to the cloud. As cloud and business use ...
Jun. 20, 2018 10:30 PM EDT Reads: 2,223
DXWorldEXPO LLC announced today that "IoT Now" was named media sponsor of CloudEXPO | DXWorldEXPO 20...
Jun. 20, 2018 09:15 PM EDT Reads: 2,665
SYS-CON Events announced today that Silicon India has been named “Media Sponsor” of SYS-CON's 21st I...
Jun. 20, 2018 08:30 PM EDT Reads: 5,436
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, disc...
Jun. 20, 2018 07:00 PM EDT Reads: 14,062
In this presentation, you will learn first hand what works and what doesn't while architecting and d...
Jun. 20, 2018 06:30 PM EDT Reads: 2,138
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22n...
Jun. 20, 2018 06:30 PM EDT Reads: 4,336
In his session at 20th Cloud Expo, Scott Davis, CTO of Embotics, discussed how automation can provid...
Jun. 20, 2018 06:00 PM EDT Reads: 5,916
Everyone wants the rainbow - reduced IT costs, scalability, continuity, flexibility, manageability, ...
Jun. 20, 2018 03:45 PM EDT
Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT...
Jun. 20, 2018 03:45 PM EDT Reads: 3,177
The standardization of container runtimes and images has sparked the creation of an almost overwhelm...
Jun. 20, 2018 01:00 PM EDT Reads: 3,204
SYS-CON Events announced today that DatacenterDynamics has been named “Media Sponsor” of SYS-CON's 1...
Jun. 20, 2018 01:00 PM EDT Reads: 10,445
Most DevOps journeys involve several phases of maturity. Research shows that the inflection point wh...
Jun. 20, 2018 12:30 PM EDT Reads: 5,209
Dynatrace is an application performance management software company with products for the informatio...
Jun. 20, 2018 12:15 PM EDT
Today, we have more data to manage than ever. We also have better algorithms that help us access our...
Jun. 20, 2018 11:15 AM EDT
Andi Mann, Chief Technology Advocate at Splunk, is an accomplished digital business executive with e...
Jun. 20, 2018 10:45 AM EDT Reads: 3,220
DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held Novemb...
Jun. 20, 2018 10:15 AM EDT Reads: 2,639