| By Yakov Fain | Article Rating: |
|
| April 13, 2005 12:00 AM EDT | Reads: |
116,368 |
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:
C:\PingPong>javac screens/PingPongTable.java
C:\PingPong>javac engine/PingPongEngine.java - Now you can run the program as follows:
C:\PingPong>java screens.PingPongTable

Naming Conventions
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:
- Name packages using small letters
- You should try to make your package/class name combination unique. There is a simple rule to achieve this: if you work for a company Best Bananas that has a Web site bestbananas.com, the URL of this Web site is guaranteed to be unique. Use this URL in a reverse order as a prefix to all your packages: com.bestnananas. If the name of your project is Shipping, add this word or abbreviation after this prefix: com.bestbananas.ship. You can further separate classes based on their functioinality, for example:
com.bestbananas.ship.invoicing
com.bestbananas.ship.delivery.Directory structure will look as follows:
com
bestbananas
ship
invoicing
delivery - Think of the future uses of your packages. For example, if the invoicing package may be reused in a different application, do not include there classes that are specific to your Shipping application.
- If you have some useful classes that perform such commonly used functions as date formatting or logging, create separate directory for them like util and log.
Published April 13, 2005 Reads 116,368
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
- Your First Java Program
- Intro to Object-Oriented Programming with Java
- Methods, Constructors, Overloading and Access Levels
- Java Exceptions
- Java Streams Basics
- Reading Data from the Internet
- Java Serialization
- Teaching Kids Programming: Even Younger Kids Can Learn Java
- Java Basics: Introduction to Java Threads, Part 1
- Java Basics: Introduction to Java Threads, Part 2
- SYS-CON Webcast: Eclipse IDE for Students, Useful Eclipse Tips & Tricks
More Stories By Yakov Fain
Yakov Fain is a Managing Director of Farata Systems, consulting, training and product company. He has authored several Java books, dozens of technical articles. SYS-CON Books released his latest co-authored book , Rich Internet Applications with Adobe Flex and Java: Secrets of the Masters in Spring 2007. Sun Microsystems has nominated and awarded Yakov with the title Java Champion. He leads the Princeton Java Users Group. He is an Adobe Certified Flex Instructor. Currently Yakov works on the book for O'Reilly "Enterprise Application Development with Flex". He twits at twitter.com/yfain.
![]() |
Howard N-H 04/13/05 02:53:31 PM EDT | |||
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 04/12/05 06:23:33 AM EDT | |||
So you can use wildcards in the import? Can you use static import for static classes? |
||||
![]() |
Java Basics series 04/12/05 06:12:49 AM EDT | |||
Will the other 10 lessons be on SYS-CON.TV? |
||||
![]() |
Java Live 04/11/05 10:17:40 AM EDT | |||
Is it Yakov Fain who is speaking at the moment? A live Java lesson - cool! |
||||
![]() |
sundeep 04/11/05 06:43:13 AM EDT | |||
I used this lesson in conjunction with the last one, lesson ten on eclipse IDE and it really helped me |
||||
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- The End of IT 1.0 As We Know It Has Begun
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- Reality Check at the Cloud Computing Expo
- Virtualization Expo Call for Papers Deadline December 15
- A Security Analysis of Cloud Computing
- IBM Sitting Pretty on Oracle-Sun Debacle
- Ecosystem is the Killer App for Cloud Computing
- The Cloud Has Cross-Border Ambitions
- Qt DevDays 2009 - Munich
- The Difference Between Web Hosting and Cloud Computing
- GovIT Expo Highlights Cloud Computing
- Cloud Computing Best Practices
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- The End of IT 1.0 As We Know It Has Begun
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- Reality Check at the Cloud Computing Expo
- Build Reliability into Cloud Computing for SMBs
- Perhaps SOA is More Strategy Than Architecture
- Five Reasons to Choose a Private Cloud
- Virtualization Conference Keynote Webcast Live on SYS-CON.TV
- Red Hat Drops Consumer Linux, Sponsors Community Led Fedora Project
- Citrix & Dell Partner on Server Virtualization
- The Top 250 Players in the Cloud Computing Ecosystem
- Red Hat CTO Keynoting Today on The Future of the Virtual Enterprise
- Red Hat Named "Platinum Sponsor" of Virtualization Conference & Expo
- Red Hat vs Sun Battle of Words Heats Up
- Forbes' "Red Hat = Linux" Spin Angers Sun Microsystems COO
- SOA, Virtualization and Web 2.0: BEA's Deputy CTO Connects the Dots
- Getting Started with Red Hat Linux
- Red Hat to Deploy "NX" vs Viruses
- Red Hat to Compete Against SourceLabs and SpikeSource

































