90 likes | 272 Views
29. Organising Code: Packages & Archives. Previously. Panels & Layout Manager Positioning Elements Layout Managers Using Layout Managers. Overview. Packages Packages Views. Packages. Projects in Java are structured in packages Packages are directories with subdirectories
E N D
29 Organising Code: Packages & Archives
Previously • Panels & Layout Manager • Positioning Elements • Layout Managers • Using Layout Managers
Overview • Packages • Packages Views
Packages • Projects in Java are structured in packages • Packages are directories with subdirectories • With .java files (development) With .class file (in .jar file) Windows Java src com src\com\aaz\sample0 src.com.aaz.sample0 aaz sample0 Eclipse view Windows view
Packages • Name of package meaningful • Java classes maybe grouped into "Packages“ • Packages have hierarchical names • The core class libraries are all in packages that start with java • The GUI classes are in the packages and sub-packages of java.awt and java.swing
Packages • Consider our Switch project • We have the project itself com.<author/company>.<project_word> • The class(es) to start the application would be in the base package for the project com.<author/company>.<project_word> • There are classes specific to generate the GUI for this project so added them into their own package, e.g. gui com.<author/company>.<project_word>.gui • Other general useful classes could be added in a general package com.<author/company>.util
Packages Views The application
Packages Views Windows Explorer Eclipse
Packages Views • If you open the bin directory then you will get the same structure than in the src directory • bin directory for .class files – compiled files • src directory for .java files – code files