Resources


Resources

Setting up Java and Eclipse

CS 2110 uses the Java Standard Edition (Java SE 8) platform. It is housed in an integrated development environment (IDE) called Eclipse. You have to get both the Java Platform and Eclipse onto your computer. We describe how to do this below..

Note that you need version 8 of Java, not version 7 or 6.

Getting Java onto your computer

Java has two main components:

Java Runtime Environment (JRE). This includes everything needed to run Java programs, including an interpreter for its machine language (the Java Virtual Machinee) and the libraries of codes of classes that come with Java.

A Java Development Kit (JDK). This includes the compiler, which translates Java programs into the Java virtual machine language. It includes a debugger, as well as lots of other pieces, which help Java work smoothly.

You can see a diagram of what each contains on this website: http://docs.oracle.com/javase/8/docs/, but don't get discouraged at its complexity. You don't need to know much more than the fact that there is a JRE and a JDK.

If you think you already have the right JRE and JDK, find out this way:

Here's how to find out which JRE you have on your computer. Open a command window (in Windows, Start > Run... and typejava -version; in Mac OS X, Applications > Utilities > Terminal) and type java -version at the command prompt. It should look something like this:

C:\>java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
... and maybe another line ...

This says you have version 8 installed (8 and 1.8 are synonymous). You might have something slightly different, like

C:\>java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
... and maybe another line ...

That's OK, as long as it is 1.8.0_something.

If this command had failed (meaning Java isn't installed at all), that would mean Java was not installed on your machine.

If Java 1.8 is not installed on your computer, you need to install it.

Which JDK do you have? If you are on a PC running Windows and have never installed a version of the Java Development Kit (JDK) on your machine, you probably don't have it. If you are on a Mac, you probably do. To find out, type javac -version:

C:\>javac -version
javac "1.8.0_74"

If you get an error message or the version is earlier than 1.8 you MUST (re)install the JDK.

Installing the JRE and JDK together

Visit Oracle's website www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

This is the site to download the latest "Java SE Development Kit", which includes the JRE and JDK. If there are more than one (e.g. 8u111 and 8u112), choose one of them, it shouldn't really matter which but choose the one with the higher number. In the main table, choose the machine on which it will be installed (your computer) and click the appropriate Download item. Once the file is downloaded, you may have to double-click the downloaded file to unpack or unzip it. Then, follow instructions to install it.

Installing Eclipse

We assume the JRE and JDK have been installed as described above.

When installing Eclipse, you will be asked where you want to put the "Workspace". This is a directory on you harddrive where all your "projects" will be kept. On the MAC, you could put it in your user directory and name it "workspace" or "eclipse". On a windows machine, you could put it in "C:\workspace".

You need the latest Eclipse version, called Eclipse OXYGEN (Release 4.70). If you have an earlier version, install the new one.

Visit http://www.eclipse.org/downloads/ This is the site to download the most recent version of Eclipse. The website says "Get Eclipse OXYGEN". Just follow directions. The site seems to know what computer/ operating system you are using. If you have a choice, make sure you choose

Eclipse IDE for java developers

You may be asked where to store the "project workspace". This is a folder where all your Java projects will be placed. Create this workspace somewhere on your harddrive where you can get to it when you want to, or, justlet Eclipse choose for you.

What if you already had a version of Eclipse on your computer

Suppose you have an earlier version of Eclipse on your computer. You should still download and install Eclipse as instructed above. Here are some things to be concerned about.

1. The folders for the old and new versions of eclipse may have the same name (e.g. eclipse). Feel free to rename the new one to something like eclipse8 before you start the application for the first time.

2. When asked where the workspace (that will contain all the projects) should be, make it the same as the workspace for the old version of Eclipse. When you do this, you may be asked whether you want all the projects updated to the new version of Eclipse. Say yes.

3. Once you try a project --e.g. running a program from inside the new Eclipse-- and you see that it works properly, feel free to delete the folder for the old version of Eclipse completely. Or, you might want to leave it there for a few months until you are satisfied that the new version is OK and then, later, delete it.

 

Compiling and running from the command line

We don't use of this feature in CS2110, but sometimes it is useful to run a Java program without launching it from Eclipse. You can easily do this; Eclipse and Java are really two different systems that talk to each other in a friendly way, but they can also be used independently. The notes that follow explain how you would run your Java program all by itself, if you wanted to do so.

Compiling

Say your method main is in class MyProgram and it is contained in source file MyProgram.java. If it is not in a package, navigate to the folder containing MyProgram.java and type javac MyProgram.java.

If it is in a package (say myPackage), the source should be in a folder called myPackage. Navigate to the folder containing myPackage and type javac myPackage/MyProgram.java.

Running

From the same folder you compiled from, type java MyProgram <program arguments> if it is not in a package, and java myPackage.MyProgram <program arguments> if it is.

Specifying a Classpath

Sometimes you may need to inform Java where to find auxiliary classes. You can do this with the -cp option to the java command. Supply a sequence of folders telling Java where to look for classes, separated by : (Mac) or ; (Windows).

More Ways To Catch Up


Piazza

CS2110 uses Piazza: a public forum for discussing questions about the assignments. The course staff monitors this group regularly, so this is a great way of getting help and interacting with the course staff. An extra advantage of using the group is that everyone else can benefit from your question as well. Anyone can visit the group and read previous questions here .

If you know the answer to a question, feel free to post a reply yourself, but please avoid giving away any hints on the homework or posting any part of a solution. This will be considered a violation of Academic Integrity. Generally, rough algorithms or non-solution-specific code fragments are OK if you need them to illustrate a point.

CS2111

In fall 2013, 60% of the incoming students won't have Java experience, and many have relatively little prior  OO experience (everyone is expected to have some programming experience, and some prior exposure to OO concepts, but the level of prior experience varies widely). To help out we've created an enrichment course that runs for 1 credit, S/U, and provides extra exposure to the same ideas we'll cover in class. CS2111 is totally optional but could be very helpful to anyone nervous about their background. It is taught by Professor Gries. You would normally take CS2111 in addition to CS2110 and the CS2110 recitation, so CS2111 does involve extra time -- one hour per week. But with this extra help, even people very nervous about programming should be able to keep up with CS2110.

Academic Excellence Workshops

The Academic Excellence Workshops (AEW) offer an opportunity for students to gain additional experience with course concepts in a cooperative learning environment. Research has shown that cooperative and collaborative methods promote higher grades, greater persistence, and deeper comprehension. The material presented in the workshop is at or above the level of the regular course. We do not require joining the AEW program, but do encourage students to join if they are seeking an exciting and fun way to learn. The AEW carries one S/U credit based on participation and attendance. The time commitment is two hours per week in the lab. No homework will be given. This is a wonderful opportunity for students to seek extra help on course topics in a small group setting.

Your fellow undergraduate students, who are familiar with the course material, teach the sessions with material that they prepare. The course staff provides guidance and support but do not actually teach the AEW course content or any session. A representative from the AEW program will be speaking about the program and registration procedures in lecture.

See the AEW webpage for further information.

JavaSummary

We have produced over 70 powerpoint slides that give a brief introduction to just about every part of OO in Java. The slides give examples, rather than formal definitions. The first two pages contain an extensive index, so you can easily get to the slides that you want.

We give it in two forms: a pdf file and the source pptx slides. The latter is the best to use so that you can make use of the animations on the slides. It took us a long time to make this up; we did it to help you. Use this resource!

CodingBat: website to practice small Java programs

codingbat.com is a website for practicing writing Java code segments to learn about and practice various Java features, from boolean expressions, strings, loops with strings, recursion, and more. Try it out!

Tutoring

One-to-one peer tutoring is available free of charge for engineering students and BEE majors enrolled in this course through Engineering Learning Initiatives’ Tutors-on-Call program. Review program policies and request a tutor at:

http://www.engineering.cornell.edu/tutoring