1 / 16

Java Coding in Eclipse

Java Coding in Eclipse. Eclipse basics. Written in Java Based on Equinox framework Modular Java specification OSGi (Open Services Gateway initiative) Dynamically loaded modules: bundles Android Development Tools (ADT) plug-in: Bundle. Eclipse Environments. Java Runtime Environment

teness
Download Presentation

Java Coding in Eclipse

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Coding in Eclipse CS440

  2. Eclipse basics • Written in Java • Based on Equinox framework • Modular Java specification OSGi (Open Services Gateway initiative) • Dynamically loaded modules: bundles • Android Development Tools (ADT) plug-in: Bundle CS440

  3. Eclipse Environments • Java Runtime Environment • Integrated Development Environment (IDE) • Modify eclipse.ini • Java Compiler: • .class files • Error messages, autocompletion (ctrl+space) • Application Runtime • Where the android emulator runs • Android Virtual Device (AVD) CS440

  4. Eclipse basic ingredients • Workspace • File → Switch Workspace → Others • Perspective • Window → Open Perspective → Other • Views and Editors • Java Perspective and Package Explorer • More info at: http://www.vogella.de/articles/Eclipse/article.html#eclipsesui CS440

  5. Eclipse Workspace • Keeps project state • Organized in directories • Different settings for different workspaces • Ex. AndroidProjects CS440

  6. Eclipse Projects • Java Project vs Android Project • Different plugins • Builder: generates artifacts • Transforms .class files to .dex files • Association • Open with.. CS440

  7. Eclipse Views and perspectives • Package explorer • Task list: todo list • Outline: code hierarchy • Problems: compiler errors, builder errors. • Other views? CS440

  8. New Project: CarDealership • Classes • Car • Public void drive(): prints “Going down the road” • Ragtop extends Car • JoyRide • driveCars • Test the Car class using: a main method in the drive cars class • Create object: myCar • test CS440

  9. More Java: Object class CS440

  10. Objects and classes • Class: • Fields (data) • Methods (procedures) • Class that inherits from another: subtype or subclass • Parent class: supertypeor superclass CS440

  11. Class Trivial • Create a trivial class with: • Fields: • private long ctr • Methods: • public void incr(): Increases ctr by 1 every time it is called • Constructor that takes as input ling initCtr • Constructor that initializes ctr to 0 CS440

  12. Object class and its methods • http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html • toString • equals CS440

  13. Objects, Inheritance, and Polymorphism • Objects of single type can have different behavior • Subtype are declared with extends keyword • Example: Cars! CS440

  14. Continue Project: CarDealership • Classes • Car • Public void drive(): prints “Going down the road” • Ragtop extends Car • Extend drive method to: • Print: “top down!” • Use superclass method • Print” “Got the radio on!” • Test ragtop CS440

  15. Continue Project: CarDealership • Class Joyride: • Fields: • private Car myCar • Methods: • Public void park(Car) • Assing field mycar to the argument • Public Car whatsInTheGarage() • Return car • Public void letsGo() • Call parkto park a new Ragtop • Call whatsInTheGarage and drive it! • Test JoyRide CS440

  16. References • Programming Android by ZigurdMednieks, Laird Dornin, G. Blake Meike, Masumi Nakamura • Eclipse http://www.vogella.de/articles/Eclipse/article.html#eclipsesui CS440

More Related