User Tools

Site Tools


start

Introduction to Java

This page contains details and references to Stanfords CS106A and CS106B classes

Karel on JRE8 Without Eclipse

There may be several reasons if you are not taking this course at Stanford why you want to run and create Karel programs on your computer without needing to install the old JRE8 or using the Eclipse environment.

This page shows a few easy steps to get Karel running on your computer with just JRE8 installed. First download and install the latest version of Java

Java Installation

Now open command prompt or if using Mac terminal window and run

java -version

Output will look something like the following if it is installed properly

java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

Next you will need a version of the karel.jar that works on JRE8 since the one provided from Stanford requires older JRE6. You can download the jar file here

karel.jar

Or if you are feeling brave you can get the latest version from github along with the source here

Stanford Karel Github

Now that we have all the software lets make sure we can launch Karel's world and see it on our computer. Lets make a blank world that extends SuperKarel and make sure it loads. Copy and paste the following code into a file called TestKarel.java in the same location as your karel.jar file

import stanford.karel.*;
public class TestKarel extends SuperKarel {
  public void run() {}
}

From the command prompt/terminal run the following command to compile your test program along with the karel.jar

javac -cp .:karel.jar TestKarel.java

Add your .class file to karel.jar

jar uf karel.jar TestKarel.class

To run your newly compiled TestKarel.class simply use

java -cp .:karel.jar TestKarel

Make sure you see the following image displayed and now you are ready to continue the training sessions from Stanford using your favorite editor and latest version of Java on your computer.

start.txt · Last modified: 2016/11/10 03:48 by 172.56.17.172