Set up your environment so you can code in Java

If you don't already have Java installed on your machine, you'll need to install it. You also may need to install an editor where you will type code.

Check to see if you already have Java installed.

On a Mac

If you are using a Mac you will use the Terminal application to execute Java programs. To see if you have a java compiler installed, open a terminal window and type:

javac -version

If you have javac installed, you'll see which version. If you don't, you'll get a command not found.

On a Windows box

Look in Program Files to see if you have a java directory, containing the jdk. If so, you have Java installed. If not, install it.

If you don't already have Java installed, install the JDK

JDK stands for Java Development Kit, and it includes the Java compiler (javac).
The JDK requires a little over half a gig of disk space. Download the JDK here:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

 

Windows users may need to fix their path

If you are using Windows you will execute Java programs from the command line. To open a command window, click on the Start menu and type "cmd" in the text box. Open a command window and type:

javac -version

If you have javac installed, and your PATH is set to see it, you will learn what version. If you get a "command not found". To put the directory where Java lives in your path, look in Program Files to see if you have a java directory, with the jdk. Make a note of the path to get to the bin directory. (You can use Ctrl+C to copy this directory name). (If you don't have a Java directory, go install Java first.)

Next, go to Control Panel and search for Environment Variables. Find under System a link to Edit the system environment variables for their account. Create a new user variable (top box). In the Edit User Variable box that follows put PATH as the variable name and then in Variable Value paste the path of the bin directory to the beginning of the variable value and then add a semicolon (;). The variable value here may look something like

C:\Program Files\Java\jdk1.8.0_60\bin

(and you must remember to add the semicolon).

 

What editor will you work in?

When you write a Java program, you'll type code into an editor. There are many to choose from. You'll probably explore several and decide what you like to work in.

Mac users already have vi on their machines, because vi is part of any UNIX platform. vi may seem outdated to GUI users, but it is a very powerful tool once you learn to use it. (Type vi at the command line to launch.)

jEdit is a nice programmer's text editor available on many platforms.

Sublime Text - cross-platform, with lot of features.

Windows only: Notepad++

Atom - built by a team at GitHub. Open source, multi-platform.

Later in the semester we'll start to explore IDEs (Integrated Development Environment), but it is good to be familiar with a text editor first. Some serious programmers prefer a text editor, some prefer an IDE. As you become more experienced, you will decide what you prefer to work in. Feel free to explore the options.