In this project, you will learn to use some of the “team” features of your preferred IDE (Eclipse or NetBeans). We will use the “Git” source code control system to allow all members of the class to work on the same project at the same time, and then to merge in your changes. This is a “real-world” way of working on code; few developers work on real projects by themselves. (And even then, version control is often useful and used.)
The project is a very simple one. The source file SayHello.java has a main method you need to edit. Add a statement to main to greet the class by displaying a unique string (so your contribution differs from other students'), which should include your name. (You are free to add additional output if you desire, such as a quote or joke.)
I have created a Git repository you can access from the
GitHub.com
. This repository contains the initial version of
SayHello.java
, a
README.md
file, a
.gitignore
file, and a bunch of other files needed for a Maven project. (There are also some Eclipse IDE project files in there, to make importing into Eclipse easier.) The initial version has a greeting from the instructor you can use as a model for your own additions. (While it is okay to be a little creative, say by adding a joke or quote, just don't go overboard and add too much!) The URL of the repo is shown below, in the step-by-step directions for each IDE. You can also view the
project's website
(generated by Maven from the initial version).
Following the directions below, you will create a GitHub account for yourself, and
clone
the current repo. (IDEs generally require a local repo to work with as well.)
You use the Git repo just like any other Java project. When you are done making a set of changes (for this project you only need to add a single line to
main
), you must
commit
your changes. That updates the local repository from your IDE's version. Next, you
Push
your changes to the class' GitHub repo. During this step you may discover another student has committed some changes after you had checked out the project. If so, you will need to
merge
your changes into the new version. You can also
update
your local copy of the project, over-writing your files with the latest ones from the repository, and make your change again.
You can perform other Git related operations with Eclipse or NetBeans. (Generally, I find the Git interface for NetBeans more intuitive than Eclipse.) It is expected that students will explore some of these operations. Eclipse assumes you may have multiple projects per repo, and thus creates a project top-level folder within the top (root) of the repo. NetBeans doesn't do that by default, but it is perfectly happy either way, so I set up the GitHub class repo using the Eclipse conventions.
Another issue is that Eclipse doesn't easily import non-Eclipse projects with existing sources. It can be done, but it was easier to create the default Eclipse project files ...
In this project, you will learn to use some of the team” features o.docx
1. In this project, you will learn to use some of the “team” features
of your preferred IDE (Eclipse or NetBeans). We will use the
“Git” source code control system to allow all members of the
class to work on the same project at the same time, and then to
merge in your changes. This is a “real-world” way of working
on code; few developers work on real projects by themselves.
(And even then, version control is often useful and used.)
The project is a very simple one. The source file SayHello.java
has a main method you need to edit. Add a statement to main to
greet the class by displaying a unique string (so your
contribution differs from other students'), which should include
your name. (You are free to add additional output if you desire,
such as a quote or joke.)
I have created a Git repository you can access from the
GitHub.com
. This repository contains the initial version of
SayHello.java
, a
README.md
file, a
.gitignore
file, and a bunch of other files needed for a Maven project.
(There are also some Eclipse IDE project files in there, to make
importing into Eclipse easier.) The initial version has a
greeting from the instructor you can use as a model for your
own additions. (While it is okay to be a little creative, say by
adding a joke or quote, just don't go overboard and add too
much!) The URL of the repo is shown below, in the step-by-
step directions for each IDE. You can also view the
project's website
(generated by Maven from the initial version).
2. Following the directions below, you will create a GitHub
account for yourself, and
clone
the current repo. (IDEs generally require a local repo to work
with as well.)
You use the Git repo just like any other Java project. When you
are done making a set of changes (for this project you only need
to add a single line to
main
), you must
commit
your changes. That updates the local repository from your
IDE's version. Next, you
Push
your changes to the class' GitHub repo. During this step you
may discover another student has committed some changes after
you had checked out the project. If so, you will need to
merge
your changes into the new version. You can also
update
your local copy of the project, over-writing your files with the
latest ones from the repository, and make your change again.
You can perform other Git related operations with Eclipse or
NetBeans. (Generally, I find the Git interface for NetBeans
more intuitive than Eclipse.) It is expected that students will
explore some of these operations. Eclipse assumes you may
have multiple projects per repo, and thus creates a project top-
level folder within the top (root) of the repo. NetBeans doesn't
do that by default, but it is perfectly happy either way, so I set
up the GitHub class repo using the Eclipse conventions.
Another issue is that Eclipse doesn't easily import non-Eclipse
3. projects with existing sources. It can be done, but it was easier
to create the default Eclipse project files and add them to the
repo. They should be ignored by NetBeans, and it shouldn't be
modifiable by Git; the repo was set to ignore changes to those
files.
You can read about using these features with your IDE using the
built in help system you have learned to use in a previous
project. For more information visit the
Git Home
, especially the
Git book online
, and the other resources found on our class web page.
Using either Eclipse or NetBeans (you don't have to use both,
although you can) complete the steps shown below for your IDE
to setup a Git project. Then edit the shared Java program, test
it, commit your change(s), and finally, push your changes back
to the central repository (merging if necessary).
The first step is to make sure your IDE includes the latest Git
plug-ins
. These almost certainly have been installed already, or you
may need to add one or more plug-ins for it. See your IDE's
documentation to see how to add plug-ins. (You can add some
others if you wish, but until you are comfortable with your
basic IDE features, I suggest you resist the temptation to install
much extra.) You should also check for IDE updates, and
install any found.
There are Windows GUI and command line tools for working
with Git and/or GitHub. They are not IDEs however; you view
your repos, create new ones, and with some tools, add files or
commit new versions of files. As the Git plug-ins for Eclipse
4. and NetBeans includes a full version of Git, you don't need any
other tool. (That is, this step is optional). Still, it is handy to
be able to run various Git commands outside of an IDE,
especially when trying to learn.
SayHello.java
// Git collaborative COP-2805C (Java II) project.
// $Id$
package mypkg;
/** Class used for COP-2805C git and GitHub project.
*/
public class SayHello
5. {
/** Displays greetings for all students.
* When done, displays a count of students who edited this file.
* @param args - Unused
*/
public static void main ( String [] args )
{
int counter = 0;
System.out.println( "Howdy! My name is Wayne Pollock." );
6. counter++;
// (1) Add your own output below these comments that
includes your name.
// (2) Place "counter++;" command after your contribution, to
keep count.
// (3) Keep the existing println statement at the very end.
System.out.println("Kevin Mock here, my code is a massive
upgrade to this program! LOL.");
counter++;
System.out.println( "Number of students who edited this file: "
+ counter );
7. }
}
README.md file
Notes:
All files are initially encoded as UTF-8. This isn't the
default for some IDEs, so you should change that in the
preferences.
Line endings of text files are Windows format (CR-LF). That
should be the default in any Windows IDE.
Gitignore file
.classpath
.project
bin