Karel the robot: errors during run
Hi, I find following errors after running the programme (a very simple one)
Exception in thread "Thread-3" acm.util.ErrorException: move: Karel is not living in a world
at stanford.karel.Karel.checkWorld(Karel.java:295)
at stanford.karel.Karel.move(Karel.java:77)
at CollectNewspaperKarel.run(CollectNewspaperKarel.ja va:16)
at acm.program.Program.runHook(Program.java:1568)
at acm.program.Program.startRun(Program.java:1557)
at acm.program.AppletStarter.run(Program.java:1895)
at java.lang.Thread.run(Unknown Source)
I have written a 3 line code:
import stanford.karel.*;
public class CollectNewspaperKarel extends SuperKarel {
public void run(){
move();
turnLeft();
move();
}
}
I do not know whats wrong with it!! its so simple still i do not why,
Stanford U CS 106A & Karel the Robot
I am new to Java. Does anyone know of a forum (or would want to start one) for Stanford Eclipse - or for their course " CS106A" ? I've had to modify or add to some of the Eclipse for JAVA assignments in CS106A in order to duplicate the problems shown in the Lectures and in the Assignments. I've had to create and save Worlds for Karel to run around in, etc. It has not been easy but I've begun to get a handle on it. I did the Turtorial "Java for Total Beginners" mentioned in this forum and that really helped. But, I seem to be spending more time trying to learn the ins & out of Eclipse rather than focusing on coding; syntax, decomposing, debugging, etc. which is the real heart of it (I think). Were I an on-campus student in the course, rather than taking the online (free!), lectures and course; I think I would have had a though time. I don't know how those kids do it. Anyway, I am here to help with what I know thus far but realize I am wasting a lot of time just getting to this point. It would be a real help to just ask: How do you create a new World for Karel to run in, save it as a Unix Executable file rather than a "txt" file and associate it with the Java Project or Java Class I'm working with. Those questions took me two days of searching and trial & error with Eclipse to find the answer.
Re: Karel the robot: errors during run
> How do you create a new World for Karel to run in, save it as a Unix Executable file rather than a "txt" file and associate it with the Java Project or Java Class I'm working with. Those questions took me two days of searching and trial & error with Eclipse to find the answer.
Several Karel examples have worlds associated with them that appear when the program is run. I would like to replicate the examples in the lectures by creating worlds (which is easy and I know how to do), but also associating them with the particular program I'm writing/demonstrating. I can use the "Load World" option, but would rather have the world loaded automatically when I run the program. Any ideas of how to do that without having the Karel code (just the .jar file)?
Re: Karel the robot: errors during run
Quote:
Originally Posted by
scotto703
> How do you create a new World for Karel to run in, save it as a Unix Executable file rather than a "txt" file and associate it with the Java Project or Java Class I'm working with. Those questions took me two days of searching and trial & error with Eclipse to find the answer.
Several Karel examples have worlds associated with them that appear when the program is run. I would like to replicate the examples in the lectures by creating worlds (which is easy and I know how to do), but also associating them with the particular program I'm writing/demonstrating. I can use the "Load World" option, but would rather have the world loaded automatically when I run the program. Any ideas of how to do that without having the Karel code (just the .jar file)?
http://see.stanford.edu/materials/ic...in-eclipse.pdf
I think you need to hit the icon of the little man rather than loading a world.
Hope that helps.
Re: Karel the robot: errors during run
Quote:
Originally Posted by
neu_mann
Exception in thread "Thread-3" acm.util.ErrorException: move: Karel is not living in a world
I just ran into this problem using standard (not Stanford) Eclipse. By now this is probably moot for you, but I'll post my solution for future travelers.
The launch configurations for Assignment 1 default to Applet, so the containing Karel application isn't launched. To solve this, create and use new Application launch configurations for each file.
If you already tried to run some of the files, delete the Applet configs created so you can reuse the names:
1. Open the project properties (e.g. right click on Assignment 1 and select Properties).
2. Select Run/Debug Configurations.
3. Select and Delete each configuration.
4. Click OK.
Create Application configs:
1. Right click on java file (e.g. CollectNewspaperKarel.java) and select Run As > Run Configurations...
2. Select Java Application in the left pane.
3. Click New Launch Configuration (the icon of a document with a +).
4. Type a name for the configuration and set its Main class to the associated file (e.g. CollectNewspaperKarel).
5. Click Apply then Run. (This should run correctly and create a useful entry in the Run History.)
Eclipse will still try to default to Applet, so you will henceforth need to launch these configurations from the Run History (either from the Run menu or the pull down on the run button). If you accidentally launch as default, it will add a useless Applet configuration to the Run History (e.g. CollectNewspaperKarel (1) ). You can delete this from the Run Configurations dialog to keep the Run History tidy.
May the Force be with you.