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
DXWorldEXPO LLC announced today that Dez Blanchfield joined the faculty of CloudEXPO's "10-Year Anni...
Mar. 18, 2018 04:30 AM EDT Reads: 726
There is a huge demand for responsive, real-time mobile and web experiences, but current architectur...
Mar. 18, 2018 01:30 AM EDT Reads: 3,095
The standardization of container runtimes and images has sparked the creation of an almost overwhelm...
Mar. 17, 2018 11:30 PM EDT Reads: 1,309
We call it DevOps but much of the time there’s a lot more discussion about the needs and concerns of...
Mar. 17, 2018 09:45 PM EDT Reads: 7,721
As DevOps methodologies expand their reach across the enterprise, organizations face the daunting ch...
Mar. 17, 2018 09:15 PM EDT Reads: 735
Digital Transformation: Preparing Cloud & IoT Security for the Age of Artificial Intelligence. As au...
Mar. 17, 2018 05:45 PM EDT Reads: 998
"NetApp is known as a data management leader but we do a lot more than just data management on-prem ...
Mar. 17, 2018 05:00 PM EDT Reads: 3,242
"Since we launched LinuxONE we learned a lot from our customers. More than anything what they respon...
Mar. 17, 2018 04:00 PM EDT Reads: 3,725
DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, ...
Mar. 17, 2018 02:15 PM EDT Reads: 5,551
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing w...
Mar. 17, 2018 02:00 PM EDT Reads: 1,755
DXWorldEXPO LLC announced today that "Miami Blockchain Event by FinTechEXPO" has announced that its ...
Mar. 17, 2018 02:00 PM EDT Reads: 2,319
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news an...
Mar. 17, 2018 01:30 PM EDT Reads: 1,584
DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held Novemb...
Mar. 17, 2018 12:30 PM EDT Reads: 3,914
With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, @CloudEXPO an...
Mar. 17, 2018 12:15 PM EDT Reads: 1,553
Modern software design has fundamentally changed how we manage applications, causing many to turn to...
Mar. 17, 2018 12:00 PM EDT Reads: 3,026
Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will ...
Mar. 17, 2018 11:45 AM EDT Reads: 6,885
As you move to the cloud, your network should be efficient, secure, and easy to manage. An enterpris...
Mar. 17, 2018 10:00 AM EDT Reads: 2,932
@DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held Novem...
Mar. 17, 2018 09:45 AM EDT Reads: 1,170
The dynamic nature of the cloud means that change is a constant when it comes to modern cloud-based ...
Mar. 17, 2018 09:00 AM EDT Reads: 3,237
"We started a Master of Science in business analytics - that's the hot topic. We serve the business ...
Mar. 17, 2018 06:30 AM EDT Reads: 3,463