Stanford Karel Robot Throws NullPointerException

I began to study the programming methodology (CS106A) available on the stanford website. But I can't get Stanford Karel into him.

I am using eclipse indigo classic 3.7.1 and 64 bit windows 7.

I wrote the following code:

import stanford.karel.*; public class CollectNewspaperKarel extends SuperKarel { // You fill in this part public void run(){ move(); move(); } } 

He gives an error

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

I followed some of the instructions given here , but then got a blank screen as output.

Destination 1 of Stanford can be found here , and karel - Stanford's robot is available here.

+6
source share
10 answers

You get this error because you are not using the version of Eclipse provided by Stanford University. For more details,

Edit: deleted this link since it no longer works.

Edit:

Since the above link no longer works, I wrote the following steps. Since I no longer use Karel, if someone has followed the guide and can make any corrections, leave a comment to edit this answer.

Instructions:

Visit the Stanford website and download the following software

  1. Eclipse for windows from Stanford
  2. Java Jre Software

B. Install the software.

Download the Assignment1.zip file from the Destinations tab.

d. Install Destination in Eclipse.

Now we are done with the installation guide. Let's talk about common issues:

Problems:

Problem 1: Blank Screen

This means that you have installed the latest Sun Java JRE software. The solution to this is I. Uninstall all versions of the JRE software except the one downloaded from the Stanford website.

OR try this

Eclipse open source software.

On the menu toolbar, click Window, and then click Settings.

from. Follow these simple steps:

  1. In the settings window, click Java.
  2. In the drop-down section shown in the Java section, click Installed JREs.
  3. The JRE we downloaded from the Stanford website is an update to jre6 2. So select it. Only jre6 is compatible with stanford eclipse software. Therefore, uncheck all other versions installed on your system and select the jre6 check box, as shown in the figure below.
  4. Click Ok. 5. Run the program. Now you can see that the output is ok.

Problem 2: Error

When you run the program, you may sometimes notice this error.

*

 *Exception in thread "main" java.lang.NullPointerException at acm.program.Program.main(Program.java:917) at stanford.karel.Karel.main(Karel.java:202)* 

*

This means that you have not downloaded the Stanford Eclipse software and are using the latest version of Eclipse that you downloaded from the Eclipse website. So follow the detailed guide that I mentioned above. Everything will work fine

+1
source

hello bhuwansahni , although I already wrote the answer, but now I am writing the whole process to launch Karel in any version of the eclipse.

  • Create a new project in your Eclipse project (File -----> New -----> Java)

  • Upload your task in the created project.

    Step a: - Extract Assignment 1 to the desired folder.

    step b: - import the destination (File -----> Import -----> General -----> File System -----> browse the folder and complete the import.)

  • Now run it differently (Run -----> Run Configurations ----->)

    Step a: - In the Apple Appet, create a new configuration.

    Step b: - In the Home section, write the main class stanford.karel.Karel

    Image for ** Step b of step 3 ] http://i.stack.imgur.com/0LpI3.jpg

    Step c: - In the section (x) = Arguments in the program arguments write code = CollectNewspaperKarel

    Image for ** Step b of step 3 ] http://i.stack.imgur.com/alIss.jpg

    Step d: - Apply and Run

  • Now here is Karel’s favorite robot.

    Image for ** Step 3 ] URL: - ( i.stack.imgur.com/d8SAa.jpg ) put http: // in front to see it ... like here I can not place more than two hyperlinks.

+5
source
 public class StoneMasonKarel extends SuperKarel { public static void main(String[] args) { stanford.karel.Karel.main(new String[] { "code=" + StoneMasonKarel.class.getCanonicalName() }); } public void run() { } } 

You need Java6.

In Eclipse:

  • Project -> Settings -> Java Compiler: select 1.6
  • Right-click the Run button β†’ Run Configuration β†’ JRE tab β†’ Alertnative JRE: select / add your Java 6 path

Then I implement the main method for each project like above. For each renaming, StoneMasonKarel.class for any name of your class.

+4
source

As this post wrote, I just figured it out, and I wrote a whole blog post to explain it further. Here is a snippet:

"So there you go. You need to download OpenJDK6 from the Ubuntu Software Center (USC). You probably already have this on your computer, but you should still check the USC just in case. Go back to Eclipse and open Windows Preferences, which should open right on the "Installed JRE" ".

More at: http://bakaripace.wordpress.com/2014/06/21/how-to-set-up-stanfords-karel-in-ubuntu-14-04-lts/

+1
source

Many times, this can be the result of not changing things like build settings. Check configuration settings in eclipse.

0
source

Be sure to use JRE6, not JRE7.

You do not need to uninstall JRE7 and install JR6 for this. Just install JRE6. In Eclipse, go to Window -> Preferences -> Java -> Installed JREs. Add the path to JRE6. In the Startup configuration, select Alternate JRE in jre6.

0
source

Perhaps this is only with Juno Eclipse, but I also needed to check the box "Enable inherited network when searching for the main class" on the "Home" tab in the "Run Configurations ..." dialog box.

0
source

Just install JRE6 and it will work. It worked for me without doing anything. Just intal JRE6 and compile with this. Change compiler type in project> properties> compiler

0
source
0
source

I had the same problem, I am running Eclipse Neon on Ubuntu, not Stanford Eclipse. I set the Argument tab incorrectly. Make sure that you have configured the run correctly.

0
source

Source: https://habr.com/ru/post/905397/


All Articles