-
Notifications
You must be signed in to change notification settings - Fork 0
Hello Java
In this tutorial, you will be covering the following topics:
- Download, Extract and Open Eclipse
- Open a project by copying and pasting source code
- Open a new project and designate a name for it
- Refactoring a project name to a desired name
- Deleting a project from the package explorer
- Open an existing project from your directory list
- Edit Source Code, then run new implementation
If you have eclipse already you can skip to section 2, where there is a supplementary video that shows how to use eclipse in action. The tutorial concludes with editing the Java source code from section 2 and running with the new implementation.
There is a student version of eclipse that can be downloaded here. There are other of versions available from the Eclipse organization listed below (CTRL + Click to open all downloads in a new window or tab).
The Eclipse Foundation also has a downloads page that covers all the version of eclipse for full scale development, click the image above for details.
After downloading the zip file, extract it with your archive opener (e.g., 7Zip, WinRar, etc.).
Once you can execute the eclipse file, it will prompt you to to select a workspace.
Opening Eclipse you will notice it does not need to install.
When selecting a workspace, keep in mind that it will hold all of your Java projects.
The image below is a video that provides an example of how to generate a Java project. (CTRL + Click to open video in a new window or tab).
The source code from the video can be copied from section 2.2
Highlight the source code below and copy it (CTRL + C or Right Click)
public class LawnMower {
/**
* The main method is the entry point to Java programs.
* @param args The arguments sent in from the command line
*/
public static void main(String[] args) {
System.out.println("This program creates a yard to a specific size...");
// create (length, width & area) variables for the yard and house
double yardLength = 0.0, yardWidth = 0.0, yardArea = 0.0;
// yardArea and houseArea calculations will be made here
yardArea = (yardWidth * yardLength);
// formatting for theses values will be output here
System.out.println("\nThe area of the yard is " + yardArea);
}
}
See more on the main method at Oracle's Getting Started Guide.
Paste the source code by right clicking in the Package Explorer and pasting the copied content.
Your project is now generated for you in the package explorer, with the following project structure.
Now that you have a project, you can now run your application. To start the Java Application, select your project by right click on it, Then select Run-As-> Java Application . You should get the following result:
This program creates a yard to a specific size...
The area of the yard is 0.0
Select File → New → Java Project and create the Java project "LawnCare". The follow the example below.
After clicking "Finish", you will have the following project structure.
Right Click on the project's name. Then select Refactor → Rename
Enter the new name that you want your project to have.
Right Click on the project's name, then select Delete.
There will be a prompt for deleting the project where you can delete it from the computer completely.
Right Click in the Package Explorer, then select Import.
Choose the option to import an Existing Project into Workspace.
Select the Browse button, then select the project folder that you want to import (e.g., LawnCare).
You will then have the directory selected where your project is, now click Finish to bring in your project under its previous project settings.
Adding the following changes to the existing source code and you will get an output showing a Yard Area.
double yardLength = 10.0, yardWidth = 10.0, yardArea = 0.0;
To start the Java Application, select your project by right click on it, Then select Run-As-> Java Application . You should get the following result:
This program creates a yard to a specific size...
The area of the yard is 100.0