I Delete a Project on Java and Want to Open Again Eclipse

Lab: Getting to Know Eclipse and Java


  • Eclipse Basics
    • Deleting a Project
    • Creating a Projection (from Scratch)
    • Creating a Java Program
    • Activating Checkstyle and SpotBugs
    • Editing a Programme
    • Adding a Library to the Build Path
    • Running a Program
  • Your Outset Programming Assignment
    • Creating a Project from the Project Template
    • Structure of a New Project
    • Creating a Program from a Skeleton (also Renaming a Java Program)
    • Your Turn
  • Submitting a Course Projection
    • Final Step: Submitting Your Project

In this lab, you will larn the basics of using Eclipse and you will write your showtime Java plan.

As you tin can encounter from the tabular array of contents above, there are three main parts to the lab. In the first part, you will learn some Eclipse basics, including how to create an Eclipse project "from scratch". Fortunately (because, equally y'all volition run across, creating a project from scratch requires many painfully boring steps), in the second part you volition learn how copying the Project Template provided for you simplifies your life; this office includes your first unproblematic programming assignment. In the third part, you will larn how to submit course projects.

It is very of import that yous follow the instructions carefully and pay attention to the details. Make certain you do not skip any steps and that you type all inputs exactly as they are provided in this guide (including spelling and capitalization).

Eclipse Basics

Kickoff Eclipse. Once y'all completed the previous lab activity, your Eclipse window should wait something like the following.

The Eclipse window is always organized according to a perspective. The current perspective determines the panels (views and editors) that are displayed in the Eclipse window. The default perspective when Eclipse is started for the outset time is called the Java perspective which is where you will do a lot of your programming work for this class. For now, just take a look around the current window: notation the menu bar at the top with a diverseness of menus (File, Edit, Assistance, etc.), the toolbar beneath it, and the diverse panels in the Java perspective (Packet Explorer, Problems/Javadoc/Declaration, etc.). The big blank expanse is where the editor will announced when you start editing your Coffee programs. This is the typical structure of most Eclipse perspectives. We'll larn more than about this in the following sections.

Deleting a Project

Before nosotros explore other features of Eclipse, let'due south delete the sample project created at the stop of the last lab (the one named MyProject ). If you already deleted it, but move on to the next section.

To delete a projection in Eclipse all yous take to do is to right click the mouse on the project to be deleted in the Package Explorer view and select Delete from the pop-up menu.

Eclipse prompts you lot to ostend your action. Unremarkably you will want to completely delete the project from the file system, so you should check the Delete project contents on deejay (cannot be undone) box and click OK.

Creating a Projection (from Scratch)

Y'all accept already seen how to create a project from a given project template at the end of the previous lab, and that is how y'all will create new projects for your programming assignments. However, it can be useful and instructive to know how to create a projection from scratch in Eclipse. A projection is similar a folder collecting the files for a given programme (or lab consignment). Eclipse supports a variety of different kinds of projects. The first step in creating a new Java program is to create a new Java project. Select File > New > Java Project.

This opens the New Java Projection magician. Enter HelloWorld as the Project name, and make sure that Use default JRE 'jre' and workspace compiler preferences is selected in the JRE section, and the Create module-info.java file checkbox is not prepare.

Click Next. On the side by side page, click End to complete the magician and create the new project.

Yous can run across your new projection in the Package Explorer view.

Creating a Coffee Plan

Now allow's create a new Java program. Select the HelloWorld project in the Package Explorer view by clicking on it (it is probably already selected). And then select File > New > Class.

This will open the New Java Class window. Brand sure that HelloWorld/src is displayed in the Source folder box (if something else appears there, click Browse... adjacent to the Source binder box to browse to and select folder HelloWorld/src ). Type HelloWorld in the Proper noun box (we could apply a different name from the name of the projection, but in this instance the same name will do). Select the checkbox adjacent to public static void chief(Cord[] args) to make sure a main plan skeleton is created. Finally click Terminate.

Hither is what the Eclipse window will look like, note that the editor console now displays the skeleton of our new coffee program.

Activating Checkstyle and SpotBugs

In this course, yous will will use two plugins (extensions) in Eclipse that will warn yous well-nigh issues with your programming style, following recommended coding conventions, and fifty-fifty some potential pitfalls with your code. These plugins are called Checkstyle and SpotBugs and are not activated past default in new projects created from scratch. And then let's turn them on.

Select the HelloWorld project in the Package Explorer view if information technology is not already selected. And then select Projection > Properties from the menu bar.

In the left console of Properties window, select Checkstyle. In the correct panel, cheque the checkbox adjacent to Checkstyle active for this projection. Also brand sure that OSU CSE is the selected configuration.

Now select SpotBugs on the left, and check the Run automatically checkbox. Click Apply and Close.

You should see a window asking for confirmation that the project needs to be rebuilt. Check Don't inquire me once again and click Yes.

In the narrow bar at the left of the editor panel, y'all should see a couple of small icons like this . These are warnings generated past Checkstyle and if you hover with the mouse on either of them, a little popular-up message will tell you what issues Checkstyle has constitute.

For now, you tin ignore these warnings. But as you learn more about Java and proficient programming practices, y'all will be expected to modify your code to remove all such warnings (and also those generated by the compiler and by SpotBugs).

Editing a Programme

Edit the programme so that it looks exactly as the following (except for the name of the author which you should change appropriately).

        import        components.simplewriter.SimpleWriter;        import        components.simplewriter.SimpleWriter1L;  /**  * Simple HelloWorld program.  *   * @author P. Bucci  */        public last class        HelloWorld {      /**      * No-argument constructor--private to prevent instantiation.      */        individual        HelloWorld() {         // no code needed here     }      /**      * Main method.      *       * @param args      *            the command line arguments; unused here      */        public static void        main(String[] args) {         SimpleWriter out = new SimpleWriter1L();         out.println("Howdy World!");         out.close();     }  }

Once you are washed typing the plan, you will see that there are some issues in the editor window indicated by red squiggly lines where issues are found and corresponding icons like this in the narrow bar at the left of the editor area (at some point you will also meet this icon which denotes a syntax error). One convenient feature of Eclipse is that it checks what you lot blazon while you type it, so it tin show you whatsoever syntactic problems with your code in real time. If you hover over each of these icons with the mouse, a popular-up note will tell y'all what problem the compiler has constitute. You can as well meet a list of all such issues in the Bug view below the editor area.

In this case, the problems Eclipse is lament about are that information technology does not know what components in the import lines is and what SimpleWriter and SimpleWriter1L in the main program are. The reason for this is that these components come from the the library of components provided for this course (we chosen information technology OSU_CSE_LIBRARY ), but we accept not told Eclipse to employ information technology in this project.

We'll fix the problems next. Now click on the Save button on the carte bar at the elevation left of the window to save your plan.

Adding a Library to the Build Path

With the HelloWorld project selected in the Bundle Explorer panel, select Project > Properties from the menu bar. In the left console of the Properties window, select Java Build Path, in the right console select the Libraries tab (if information technology is not already selected) and click Add Variable....

In the New Variable Classpath Entry window, select OSU_CSE_LIBRARY (you may need to scroll to the cease of the list) and click OK.

The OSU_CSE_LIBRARY has now been added to the build path for this project, so click Apply and Close to become back to the editor.

The errors should accept disappeared. If you happen to however have a alert on the commencement line of code maxim "File does non finish with a newline." only get to the last line in the editor and printing Enter. Salve the program and all warnings and errors should exist gone.

If you yet have any errors or warnings, try to effigy out how your plan differs from the ane to a higher place and prepare it accordingly (or call an instructor and ask for assist).

Running a Program

Now information technology's time to run your first program. To run the plan, select Run > Run from the menu bar.

Afterwards a short fourth dimension, the program will start and a new tab labeled Console will announced in the bottom pane. This is the space where you will exist able to collaborate with your programme, i.eastward., this is where the output of the program volition be displayed and where you volition be expected to type any inputs your program needs. If the Console tab is not the meridian one, simply click on its name and it volition exist brought in the foreground.

The program prints Hello World! in the Console and then terminates. Congratulations! You accept just entered, compiled, and executed your first Java programme in Eclipse. Of course, there is a lot more than to larn about the Eclipse surroundings, but you have already used the most key features that you volition demand in this grade.

Your Showtime Programming Assignment

Creating a Java project and program from scratch was pretty laborious. Permit's see how using the ProjectTemplate project makes things simpler and faster.

In this office of the lab yous will create a new Java project from the projection template and and then modify one of the simple skeletons included in the template to write your first Coffee plan.

Creating a Project from the Project Template

Create a new project past copying and pasting the ProjectTemplate project and name your new project HelloJack. The detailed instructions with screen shots can be found here and are briefly summarized below.

  1. In the Parcel Explorer view, click the right mouse button with the mouse arrow on the ProjectTemplate project entry and select Re-create from the pop-up menu.
  2. Click the right mouse button anywhere in the Packet Explorer view and select Paste from the pop-up carte.
  3. Enter the name for your new project and click OK.

Structure of a New Projection

Take a minute to explore your new project. If you expand it in the Package Explorer view, you can run across several folders (src, test, data, doc, and lib) and some libraries (Referenced Libraries, JRE Organization Library, and JUnit 4). You will larn about the purpose and significance of each of these during the semester, but for now, just aggrandize the src binder which, of course, is meant to contain your Java source files.

Further expand the (default package) entry to see several Java files: HelloWorld.java, ProgramSkeleton.java, ProgramWithIO.java, and ProgramWithIOAndStaticMethod.java. Again, each of these volition exist explained after on. Right now open HelloWorld.java in the editor by double-clicking information technology in the Package Explorer view. The program looks pretty much the same as the i you entered earlier, but observe that in that location are no syntax errors nor warnings. Ane of the squeamish things about using the project template to create a new project is that it already has all the right settings needed: the right libraries on the build path, Checkstyle and SpotBugs are already activated (though you cannot meet that because in that location are no bug with the Coffee programs provided), and there are several folders that will exist useful later on.

Anyway, you tin can shut all the open tabs in the editor by clicking on the X on each tab.

Creating a Plan from a Skeleton (also Renaming a Coffee Programme)

To create a new Java program y'all can either get-go from scratch the style y'all did before in this lab, or yous can merely rename one of the given skeletons and beginning editing that. Allow'due south effort the latter.

Open the ProgramWithIO.java file past double-clicking on information technology in the Package Explorer view. Take a look at this skeleton. Its structure should look familiar.

Since y'all probably take no reason to name your program ProgramWithIO.coffee , you should rename it to accept a more meaningful proper name. In this case, you should rename it HelloJack . This can exist easily accomplished without fifty-fifty editing the file. Recollect that in Java the name of the program (given later public last class ) and the name of the file that contains it must friction match. In Eclipse, information technology is like shooting fish in a barrel to alter both at the same time.

Correct-click on the ProgramWithIO.coffee file in the Packet Explorer view and select Refactor > Rename... in the pop-up menu.

In the Rename Compilation Unit window, enter the New name HelloJack and click End.

Eclipse will warn you lot that because you are renaming a main program some applications could suspension. However, in this case, no application is using this program and there is no danger in irresolute its name. Click Finish once more.

The result is that the file has been renamed HelloJack.java and the program has been renamed HelloJack correctly and as expected.

Notation: once you lot have chosen the skeleton file to use as a starting point for your own program, you can delete the other files from the project. This is hands accomplished past right-clicking on each file in the Package Explorer view and selecting Delete from the popular-up menu (or you tin also but select the file(southward) in the Bundle Explorer view and printing the Delete cardinal on your keyboard).

Your Plow

Finally you become to write some Coffee. Change the HelloJack program then that it prompts the user for his/her name, inputs the proper name, and outputs the message Hullo, <proper noun> where <name> is the name entered by the user.

Once y'all are done, make certain there are no errors, run the program a few times with different inputs to see whether it does what it should and, if not, ready the problems until y'all go it to work every bit expected.

Submitting a Course Project

Whenever you lot demand to submit a class project, y'all will first create a ZIP archive file of your Eclipse project and a PDF "printout" of your code. You lot volition submit these files through Carmen.

Detailed instructions on how to create the ZIP archive of an Eclipse project and how to generate a PDF printout of your Java code are available here.

Concluding Step: Submitting Your Project

To make sure you lot understand how to submit your work, create a ZIP archive file of the project yous but completed (the 1 containing HelloJack.java) and a PDF printout of HelloJack.java post-obit the instructions at the link higher up, and submit that ZIP file and PDF file in Carmen under the dropbox for this lab.

Please notation! This submission is Non going to be graded. None of your other in-class labs volition demand to be submitted, either. This submission is only do and then that you lot know how to submit your projects.

barilescompe.blogspot.com

Source: http://web.cse.ohio-state.edu/software/2221/web-sw1/extras/instructions/getting-to-know-eclipse/getting-to-know-eclipse.html

0 Response to "I Delete a Project on Java and Want to Open Again Eclipse"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel