2

I run this command to compile, it runs successfully:

javac -d . -cp .;KarelJRobot.jar StairClimber.java

Then I use this to try and run my class:

java -d –cp .;KarelJRobot.jar StairClimber

and I get this:

Error: Could not find or load main class ûcp

This is the entire class file:

import kareltherobot.*;

public class StairClimber {
    public static void main(String[ ] args)
    {   
        /* You fill this in */
        World.setVisible(true);
    }
}

I got the Karel Simulator from here:

http://csis.pace.edu/~bergin/KarelJava2ed/KJRDistribution060110.zip
Jason Plank
  • 2,336
  • 5
  • 31
  • 40
Hudspeth
  • 146
  • 13

2 Answers2

5
java -d –cp .;KarelJRobot.jar StairClimber
--------^

Your cp argument hyphen is wrong. You need the - one next to 0 on your (US) keyboard. Do not copypaste the command from some PDF file or website. Enter the command all yourself.

java -d -cp .;KarelJRobot.jar StairClimber
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • +1 nice catch. I totally missed the significance of the "ûcp" :\ – Ryan Stewart Sep 21 '11 at 02:45
  • I wish I could +1 you man, thanks so much. It was from a PDF. I copy and pasted from it. – Hudspeth Sep 21 '11 at 02:51
  • 1
    You're welcome. Hope that you'll stop copypasting code. Getting it out of your own fingers will end up it to be better remembered and practiced. Seriously. – BalusC Sep 21 '11 at 02:53
-1

Try using the below (also, : instead of ;) :

java -cp .:KarelJRobot.jar StairClimber

Saket
  • 45,521
  • 12
  • 59
  • 79
  • That would not have resulted in this error (how else would you explain it? and also that he successfully compiled it?). The colon is specific to *nix environments by the way. The semicolon is perfectly valid on windows environments. – BalusC Sep 21 '11 at 02:43