1. Setup
1.1. Java Tools
Download and install the Java Development Kit (JDK) version 8. Make sure that you select the appropriate link for your Operating System (Windows, OSX, Linux) and its version.
1.2. Eclipse
The instructor will be using Eclipse in class. You do not have to install Eclipse, you can select to use a different IDE. We will try and help you regardless of your IDE but be prepared to do some work on your own if you select an IDE other than Eclipse.
1.3. Test your Setup
-
Open your newly installed IDE.
-
Create a new Java project.
-
Create a Java file called
Author.java
and copy paste the following code
-
In Eclipse, right click on the file name
Author.java
. -
Select
New
from the pop-up menu -
Select
JUnit Test Case
from the pop-up menu -
A new window will popup. In the middle of the new window select
-
setUp()
-
tearDown()
-
-
Click Next
-
After clicking Next a new window will east all the available methods on the class
Author
for which we want to write a test. SelectgetName()
-
Click Finish
-
Eclipse will ask you if you would like to add
Junit
4 in your build path. Click OK -
Eclipse will generate a stub test class for you that should look like the one below.
-
Select
AuthorTest.java
on the Package Explorer Window. -
Right click while
AuthorTest.java
is selected. A pop-up menu will appear. -
Select
Run As
from the pop-up menu. -
Select
JUnit Test
-
Eclipse will alter some windows around, mainly your Package Explorer Window. The results of your test run appear at the same location as the one occupied by the Package Explorer window. Your test should fail.
2. Eclipse and Git
Your typical workflow would be
-
Check out your repo from CCIS Github.
-
Create a new Java Project in Eclipse
-
Right click in the Package Explorer window
-
Select
New
-
Select
Java Project
-
In the pop-up window
-
Type a name for the Eclipse Project. This can be any name you like
-
Unselect
Use default location
. This action will enable the kdb:[Browse] in the line line immediately below. -
Click Browse and navigate the directory on your computer in which you checked out your repo (see Step 1)
-
Click Finish
-
-
Because we pointed Eclipse to a directory that contains a Git repo, Eclipse will load its Git extensions. To see the Eclipse Git extensions in action
-
Expand your project in the Package Explorer window until you find the file
Readme.md
-
Select the file
Readme.md
. -
While the file
Readme.md
is selected, right click to access the pop-up menu. -
In the pop-up menu find the option named
Team
. -
The sub-menu options under
Team
should look familiar/identical to Git commands, e.g.,Commit
. -
The menu
Repository
nested inTeam
contains actions that let you push/pull from the server, i.e.,-
Push to Upstream
-
Fetch from Upstream
-
There is already a repository created for you on the CCIS github with the name lab1-<login>
where <login>
is your CCIS login name.
Check the repository to your desktop. Create a new Java project in Eclipse and move (copy/paste) all your code in your new Java Project.
Push your code to the CCIS Github Server using Eclipse.
3. Creating new classes
We decided to update our Author
class. Instead of holding an author’s name as a string, we would like to create a new class called Person
that
will hold
* a person’s first name, and,
* a person’s last name.
4. Creating more classes
We also decided that we need a better way to capture email addresses. Using a String
is not convenient.
5. Javadoc
For all the code that you have written up to this point in the lab should have also written documentation for it.
If you have not, go back and add documentation now!
Lets generate the HTML version of your code’s documentation.
-
Select your project in the Package Explorer window.
-
On the Eclipse main menu found at the top of your window (or the top of your screen on a Mac), click on Project menu item.
-
From the pop-up sub-menu of Project select Generete Javadoc…. A new window will appear.
-
In the new window you will see a list of all your Eclipse project. Select the project that you have been working on during this lab.
-
Towards the bottom of the window you will see a Browse button. Click Browse and designate the destination folder on your computer to store the generated documentation files. These are going to be HTML files that you can open with your browser.
-
Click Finish
-
Observe that at the bottom window in Eclipse you can see the progress of the javadoc generation including any errors and warnings. Make sure that there are now errors or warnings. If you have some, click on the error/warning and it will take you to the correct file and line to fix the error. Consult Javadoc documentation if you have to.
-
On your computer navigate to the folder that you selected as the destination for the generate documentation and open the file
index.html
.
6. Classes again!
We would like to capture addresses more precisely than just using one long String
.