Setting up Karel the Robot In Eclipse

Exception in thread "main" java.lang.NullPointerException
	at acm.program.Program.main(
	at stanford.karel.Karel.main(

If you are getting this error after you tried to run “Karel the robot” , you are not alone.
Apparently, if you download the version of eclipse that Stanford provides you are unlikely to get the error but if you are like me trying to run your own version of eclipse you will likely get the error.

Here is how to fix it:


Manage to get your application into eclipse. Follow the Stanford tutorial


Click on “Run as Configuration”


Change the main class settings to “stanford.karel.Karel”


Then probably the most important step: Enter “code=CollectNewspaperKarel” in program arguments under the arguments tab.
Click on Apply and then Run your program.

Final Result (Eclipse Indigo)

That should be it.  This was supposed to be easy apparently.

Interesting links:

Let's share thisShare on Facebook
Tweet about this on Twitter
Share on LinkedIn

17 comments Write a comment

  1. What java SE JDK version are you running with eclipse indigo? I still can’t get Karel to work. I am runninig windows 7, eclipse indigo, Java SE development kit 6 (update 30).

  2. I was running java se 6 version 29. I just updated java to version 30 and it still works. Note that i had to reboot the machine after updating to version 30. It would not work without a reboot.

  3. OMG THANK YOU. I spent a day trying to fix this problem, checked a half dozen sites none of which helped. Downloaded the Stanford eclipse, STILL didn’t work. The only thing I was missing was “code=CollectNewspaperKarel” which NONE of the other sites mentioned and WASN’T included in the Stanford download. Thank you so much!!

  4. Definite timesaver. I opted for Java EE rather than the Stanford package and was banging my head against the keyboard. Much obliged!

  5. Hi this doesn’t work for me-i still get the blank box (withe the assignment as the title..’NewsPaper…’ and underneath that the word ‘File’ but the images do not appear it stays blank,there are no errors in the problems tag,i’m using a PC on XP Pro tried with both Eclipse indigo and Helios(stanfords own) both with same result, oh im using JRE7 JDK 1.7.? ?. Has anyone got this working on JRE7 or just JRE6 mayby idk, any help would be appreciated.Thank you.Lee

  6. Many thanks. Nothing is more frustrating than a major exception right out of the gate, thanks for providing such a quick and concise fix!

  7. @Lee: Hi Lee – I had the same problems too trying to run Karel using JRE7/JDK1.7.

    Changing to JRE6/JDK1.6 solved the problem. I’m assuming that there is something in the Karel code that has changed between Java versions.

    Hope this helps clarify for you.

  8. I am using both the version of Java and of Eclipse downloaded from the Stanford site, thinking that things would be smoother if I used the exact software the assignments had been written for. Unfortunately the “run as configs” option is not available; all I get is “run as eclipse application” and “run as equinox framework”. I have no idea what to try next. I am using the Stanford perspective as suggested