Resources


Resources

Setting up Java and Eclipse

In CS 2110, you'll be using an integrated development environment (IDE) called Eclipse to develop and debug your applications, which will be coded in the Java Standard Edition (Java SE 7) platform, as released by Oracle and downloadable from Java.Oracle.com.

Java SE 7 includes a Java Development Kit (JDK) as well as the Java Runtime Environment (JRE). The way to think about all of this is that the Eclipse IDE is a "digital dashboard" and code editor for writing code and performing commands like compiling your program, pulling in standard libraries, identifying problems and fixing them. Under the covers, the IDE is giving you a kind of friendly interface to the JDK, which has all sorts of standard libraries.

The JDK is like a computer (sort of a computer within your computer) that can run the resulting code. While it is running the JRE is handling things like opening files for your program. If you prefer to just think of the JDK and JRE as two parts of one thing, that would be fine.

The IDE we use in CS2110 is Eclipse, and we use this even though Oracle has its own IDE for Java. The version of Eclipse we work with is the "Juno" release.

We recommend that you start by installing Java and then installing Eclipse. Alternatively, try to find one of the "combined" Eclipse install packages that includes both Eclipse and Java and installs them both at once (but they don't exist for all possible platforms, unfortunately, and it actually looks as if the Eclipse folks have been phasing them out). If you follow the steps, this should work for most students on most platforms. But some mixtures of computers and versions of the operating system and so forth confuse the install scripts. For those cases, our CS2110 consultants can help.

Some cs2110 students installed Java on their machines a while ago and try to cut corners and skip this install step. That can be a mistake if that version of Java is too old. You want version 7. 

To find out which version of the Java Runtime Environment (JRE) you are running, open a command window (in Windows, Start > Run... and type cmd; in Mac OS X, Applications > Utilities > Terminal) and type java -version at the command prompt:

C:\>java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

This says I have version 6 installed (6 and 1.6 are synonymous). 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.7 is not installed on your computer, you need to upgrade to it.

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.6.0_07

If you get an error message or the version is earlier than 1.7, you must (re)install the JDK.

Installing the JDK

The easiest way to install the JDK is to jump down to the link for installing Eclipse, below, and follow that.  Then select the option for installing the JDK and JDE as part of the Eclipse install. In one easy (but slow) download, you'll have everything you need. But if you can't find a combined package for your machine, which is an issue lately, you may need to first install the JDK by itself and then install Eclipse by itself. In what follows we'll explain how to do this.

The JDK is already installed in CIT and ACCEL labs. However, installing it own your own machine will greatly facilitate your work. Please note that you should double check your work in a public lab, since privately owned machines occasionally exhibit different behaviors.

Windows and Unix

To download the JDK, visit Oracle's Java web site and download and install JDK 7. You may run into mention of "Sun", that's just the name of the company that created Java. Sun was eventually acquired by Oracle, and these days, Oracle runs the Java development effort.

Mac

If you have a 64-bit Intel-based Mac running Mac OS X 10.5 (Leopard), there is a version of Java SE 7 available from Apple. If you wish to upgrade, visit Apple's Java web site and download and install Java for Mac OS X 10.5, Update 1. After installing, run Applications > Utilities > Java > Java Preferences. Drag the newly installed version of Java to the top of the list under Java Application Runtime Settings. Click Save.

Disabling the Java 1.7 Plug In in your Browser

Annoyingly, the US Department of Homeland Defense chose this specific moment to announce that there is some sort of gaping security problem with version 7 (not prior versions) of Java, but that it only applies to use of Java as a web-browser plug-in (aka add-on). We don't plan to use Java as a web-browser plug-in, but you might already have been doing so, and as a result you might already have a security problem with your browser. If you didn't but you just upgraded to JDK 1.7, you might have just created a problem.

To deal with this, go to your browser control panel, click to the page that they use to manage plug-ins or add-ons, see if Java is listed as one of them (it might not be; not everyone is using Java this way), and if it is there, disable it. Then restart your browser.

Here is a webpage from 14 January 2013 that discusses the issue:

Installing Eclipse

Once you have the Java JDK installed, and have secured your web browser against terrorists, visit http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/junosr1 and follow the installation instructions you'll find there. In principle, if you installed Java correctly, the Juno release of Eclipse will find it. If not, you may need to create a shortcut to the version of "javaw" Eclipse should use when it needs to launch the Java system. Our consultants can help if you get into this situation, which occurs mostly if you do things in the wrong order or if you had an old copy of Java on your machine and Eclipse became confused.

When you download and install Eclipse, as long as you select the "Java Personality" for the package, and your computer is one of the supported ones, you can also download and install the JDK and JDE all in one monster file. We mention the personality because Eclipse can also be used to develop code in other languages like C++, and it can be used to create applications that run on the desktop (our kind), on servers (we won't do this), as new libraries, etc. If you get confused and use the wrong personality, Eclipse will complain but nothing horrible will happen and you can usually poke around until you get to the home page, then select the personality you really wanted (Java) and then you should be in better shape.  Each of your homework assignments will be a separate Eclipse "project", but you can use the results from one assignment as a basis for the next, and in fact we'll often do so.

Compiling and Running from the Command Line

We don't make much use of this feature in CS2110, but sometimes it is useful to run a Java program without launching it from inside 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 main class is MyProgram and it is contained in the 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).

Brushing Up

For students with limited Java experience, we recommend the online notes from CS 1130 (formerly 101J), Transition to Object-oriented Programming as a refresher. This is a self-paced course consisting of several modules that you can go through at your leisure.

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 a bit of 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 giev 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!