You will need to install the following:
JDK 8 e(for Windows, Linux, or OS X): From this page, download JDK under Java SE 8u65 / 8u66 (you don't need Server JRE, JRE, Netbeans, demos, or samples).
Eclipse 4.5 (a.k.a. Eclipse Mars.1): Follow the instructions to download and install Eclipse with the package Eclipse IDE for Java Developers (if you need to determine whether to install 32- or 64-bit Eclipse, see: Windows). The latest version of Eclipse is required.
If you already have Git installed, you do not need to install the latest version. Windows users should look for the Git shell. OS X & Linux users should try running git
in a terminal.
The Git site should prompt you to download the appropriate version. Follow the instructions of the executable.
Windows:
On the Select Components page, choose all the selected components plus at least one of the Additional icons (this creates a Git Bash shortcut which you will use for all Git commands).
Choose Use Git from the Windows Command Prompt and Checkout Windows-style, commit Unix-style line endings (and defaults for the rest).
The Eclipse integrated development environment (IDE) is a powerful, flexible, complicated, and occasionally frustrating set of tools for writing, modifying, and debugging programs. It is especially useful for working in Java.
When you run Eclipse, you will be prompted for a “workspace” directory, which is where Eclipse will store its configuration and metadata. The default location is a directory called workspace
in your home directory. You should not run more than one copy of Eclipse at the same time with the same workspace, or the metadata will become corrupted. Choose a place to put your workspace and continue.
The first time you run Eclipse, it will show you a welcome screen. Click the “Workbench” button and you’re ready to begin.
You may store your code in the workspace directory, but this is not recommended. On the left side of your Eclipse window is the Package Explorer, which shows you all the projects in your workspace. The Package Explorer looks like a file browser, but it is not. Don’t be fooled — it rearranges files and folders, includes things that are not files or folders, and can include projects stored anywhere on disk that have been added (but not copied into) to the workspace.
Windows & Linux: got to Window → Preferences.
OS X: go to Eclipse → Preferences.
In preferences, go to Java → Installed JREs. Click Java SE 8 and then the Edit... button. In the "Default VM arguments" box enter: -ea
(which stands for enable assertions). And click Finish.
In preferences, go to Java → Code Style → Formatter. Click the Edit... button next to the active profile. In the new window, change the Tab policy to "Spaces only." Keep the Indentation size and Tab size at 4. Enter a new name for the profile and click OK.
For this class, we are using Git for you to turn in all your problem sets and coding exercises. We need you to set up your MIT Github account for this. However, we still want you to use the commandline for all other needs to better prepare you for future classes.
Go to https://github.mit.edu and log in with your credentials. (This will automatically create an account for you.)
At the top right hand corner, click the Settings wheel, and go to Profile. You can add an email to receive notifications.
Within Settings, go to Applications, and click Generate new token. The default checked scopes are fine. Give it any description you want. You will need this token when cloning your repo because the system does not know (or use) your MIT kerberos password.
Once we've added you to the 6.178 organization you should receive an email if you asked to be notified in Step 2. If not, go to https://github.mit.edu/6178-iap16 to accept the invitation. If you did not receive an invitation by the start of class, please email the staff.
Before using Git, let's do some required setup, and make it behave a little nicer.
Every Git commit includes the author's name and email. Make sure Git knows your name and email by going to the terminal (Git Bash on Windows) and running:
git config --global user.name "Your Name"
git config --global user.email username@mit.edu
Every Git commit has a descriptive message, called the commit message. Configure the default text editor you will use to write them.
nano is a simple text editor. It does not come with the Windows version of Git, so Windows users should choose a different option.
To see if you have nano, try running:
nano
in the terminal. The result should be a simple editor with instructions at the bottom of the screen; quit with ctrl-X
. If that worked:
git config --global core.editor nano
will configure Git to use the nano editor. The commands to use the text editor (like copy, paste, quit, etc) will be shown on the bottom on the screen. The ^
symbol represents the ctrl
key. For example, you can press ctrl-0
to save (name calls it "write out") and then ctrl-X
to quit.
You can change the default editor to Notepad with:
git config --global core.editor notepad
If you prefer to edit your commit messages in the terminal, choose the next option instead.
On OS X and Windows, your default editor will be Vim. On Linux, the default editor depends on your distribution.
Vim is a popular text editor, but it’s tricky to use.
Before making your first commit, try running:
vim
in the terminal.
You start in a mode called “normal mode”. You can’t immediately type anything into the file!
In order to start typing, press i
(stands for “insert”). This will bring you to “insert mode”, so named because in this mode you can type text into the file.
When you are done typing, press esc
. This will bring you back to “normal mode”.
Once you’re back in normal mode, you can type commands that start with :
.
To save your work, type :w
(stands for “write”) and press return.
To exit (quit) Vim, type :q
and press return.
To save and quit in one command, combine them: type :wq
and press return.
Out of the box, it can be hard to see and understand all the output that git prints out at you. One way to make it a little easier is to add some color. Run the following commands to make your git output colorful:
git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto
git config --global color.grep auto
LOL.
As we’ll see later on in the course, git log
is a command for looking at the history of your repository.
To create a special version of git log
that summarizes the history of your repo, let’s create a git lol
alias using the command (all on one line):
git config --global alias.lol "log --graph --oneline --decorate --color --all"
Now, in any repository you can use:
git lol
to see an ASCII-art graph of the commit history.
This document is based on the 6.005 Getting Started Notes.