1 / 26

Some Tips for Using Eclipse

Creating and running a Java program. Some Tips for Using Eclipse. Create a New Java Project. Create new Java Project. File/New/Java Project. Create New Project – Give it a name. Name the project. Add a class to the project. Right-click on src . Select New/Class. New project is open.

palila
Download Presentation

Some Tips for Using 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. Creating and running a Java program Some Tips for Using Eclipse

  2. Create a New Java Project Create new Java Project File/New/Java Project

  3. Create New Project – Give it a name Name the project

  4. Add a class to the project Right-click on src. Select New/Class New project is open

  5. Adding a new Driver Class Give the class a name If this is the driver class, add a main method Make sure this is checked Click Finish

  6. Generated code Fill in class purpose Fill in method description Fill in body of main method

  7. Add Another Non-Driver class • Use same technique without a main method Class name

  8. Add desired attributes

  9. Generate Default Constructor Deselect All to Generate Default Constructor Select both Select me

  10. Default Constructor Fill in the Description Fill in the body of the default constructor

  11. Generate Parameterized Constructor • Follow the same process but do NOT deselect the attributes (fields) • All of the following code is generated

  12. Resulting code so far . . . Fill in purpose Fill in parameter details

  13. Generate Getters and Setters Choose those you want Remember it is not always desirable to have getters and setters – depends on what needs to remain private Select me

  14. Added Getters/Setters Depending on which are selected in the previous dialog, a series of getters and setters like this is generated

  15. Other code generators Comment out (or uncomment) the selectedlines of code Add a block of comments to a method you have written Generate a toString method for your class Generate hashCode ( ) and equals ( ) methods

  16. Renaming an attribute or method • Use Refactor / Rename to change the name of a method or attribute of a class, a localvariable, parameter, or even the name of a class. • This changes the name everywhere it appears in the code.

  17. Which import do I need? If you refer to a class that is not in your ownproject or in anyimportedclass, Eclipse puts a redsquigglyline underneath the reference

  18. Let Eclipse help you select the right import • Hover the mouse cursor over the underlined word and a tool-tip will appear; choose what you want from the tool-tip and Eclipse does rest Click this choice

  19. Alternatively, do this • Press ctrl-shift-O (letter O, not zero) and Eclipse will fill in the correct import for you or it will list possible imports and let you choose one

  20. Running a program Right-click on (or in) the driver (code) To run a program

  21. Another way to run the program … Click me

  22. Submitting a project … from your workspace

  23. Project Folder Contents in Workspace Contains .java files for your project Contains the compiled .class files

  24. The bin folder This folder contains the compiled .class files. Do NOT submit them.

  25. The src Folder .java files for the project Zip ONLY these files, naming the zipped folder appropriately. DO NOTzip the containing folder (src or DemoProject1) If you are using a non-Windows machine such as a Mac or a Linux machine, it is your responsibility to be sure your system does NOT add extraneous folders and other items to your zipped folder.

  26. Zipping the files Select the files to be zipped and right-click … some other archiving tool such as 7-zip Use SendTo Compressed Folder or …

More Related