0

I've been trying to make CS106A work on my computer for ages, and it seems that I am missing out on a huge part of my Java education, because I keep on hearing stuff about dependencies, and classpaths, and have entered in too many lines into cmd that I have no idea what they did.

My most recent problem has been when I was merely testing the Karel program, I imported it like it said I should on IntelliJ's website, and I think I got most things right, the karel.jar is in the dependencies tab and whatnot, but when I try to run this code it says "Cannot resolve symbol 'CollectNewspaperKarel', I have no idea what its referring to, and all the other answers that I've seen talk in some gibberish that I don't understand. So if someone could explain to me the massive hole in my knowledge, or at least what its called so I can watch a video on it... that would be great. enter image description here enter image description here enter image description here enter image description here

/*
 * File: CollectNewspaperKarel.java
 * --------------------------------
 * At present, the CollectNewspaperKarel subclass does nothing.
 * Your job in the assignment is to add the necessary code to
 * instruct Karel to walk to the door of its house, pick up the
 * newspaper (represented by a beeper, of course), and then return
 * to its initial position in the upper left corner of the house.
 */

import stanford.karel.*;

public class CollectNewspaperKarel extends Karel {
    public void run() {
        move();
        turnRight();
        move();
        turnLeft();
        move();
        pickBeeper();
    }
}
Stefan Becker
  • 5,695
  • 9
  • 20
  • 30
  • 1
    please don't show a load of print screens. show us the actual code. chances are, you are initializing it wrong, or you don't have a correct import statement – Stultuske Feb 13 '19 at 08:02
  • @Stultuske apologies, however, what are the chances where, the code is at the bottom, how have I imported it wrong? and whats initializing... – Agustin Fitipaldi Feb 13 '19 at 08:06
  • @AgustinFitipaldi please see https://stackoverflow.com/a/43319356/104891 – CrazyCoder Feb 13 '19 at 08:07
  • Which class/line shows the error? I don't think it appears in `CollectNewspaperKarel` class. – Jai Feb 13 '19 at 08:09
  • @AgustinFitipaldi are you actually using a professional IDE while not knowing what initialization is?? how did you manage to compile the class, if it doesn't compile??? – Stultuske Feb 13 '19 at 08:12
  • @Jai no line shows the error, that's part of the problem, it only arises when I go to compile and run it, as shown in the 3rd screenshot – Agustin Fitipaldi Feb 13 '19 at 08:13
  • @Stultuske I didn't manage to compile the class, thats where I'm having trouble, if you're asking about the CollectNewspaperKarel.class, that was already there. – Agustin Fitipaldi Feb 13 '19 at 08:14
  • @AgustinFitipaldi that .class file IS the compiled version. Do you know the very basics of how Java works? – Stultuske Feb 13 '19 at 08:16
  • @Stultuske hehehe, apparently not, but back to actually solving issues, would you mind explaining what this is all about? – Agustin Fitipaldi Feb 13 '19 at 08:18
  • well ... this is about you using tools you don't understand, and wondering why you can't get it to work. it's really as simple as that. Your description is vague at best, and you yourself indicate you don't have the basic knowledge you would need to even get to such kind of error. – Stultuske Feb 13 '19 at 08:25
  • I'm pretty sure you have another class that holds the application entry point (i.e. the `static main()` method). That class definitely used the `CollectNewspaperKarel` class, which you probably did not even place in `src` folder. – Jai Feb 13 '19 at 08:27
  • @Jai Thank you for being helpful, and this brings me to my next question, I remember making a project file and seeing that src folder, but I cant seem to find it in IntelliJ, when I find such a folder, would I merely transport all the class files over there? – Agustin Fitipaldi Feb 13 '19 at 08:32
  • @Stultuske Yes, thank you for answering the obvious, I don't understand. However, I would greatly appreciate it if you could, instead of remind me of the fact that I am just learning this language, actually help me in answering my question. Which sounds like shouldn't be a problem for you – Agustin Fitipaldi Feb 13 '19 at 08:33
  • @AgustinFitipaldi there are only so many ways I can tell you that you haven't provided nearly enough information. Seriously, if you want to avoid issues like this: uninstall IntelliJ, buy a good textbook on Java, or go through the official documentation, and learn Java from the beginning – Stultuske Feb 13 '19 at 08:34
  • @Stultuske pardon, let me tell you where I am, I have begun taking the CS106A (Programming Methodology class at Stanford, supposedly requires no previous experience), I have gotten "The Art and Science of Java" Textbook for that class. I'm not sure what more information I can give you. I have a .java file I want to compile in an imported project file, and its giving me said error – Agustin Fitipaldi Feb 13 '19 at 08:37
  • what do you mean "I want to compile IN AN IMPORTED PROJECT"? You are not supposed to change anything about imported projects. Your code goes in your own. btw, just took a glance over the book you're following. I'm starting to understand why you don't know the basics. Your teacher has you (from moment 1) using inheritance without as much as bothering to explain what it is/does. – Stultuske Feb 13 '19 at 09:02
  • @Stultuske Hahahahaha, it seems like there's a whole fuckbucket of stuff wrong then. What course of learning would you suggest so that I learn Java properly? – Agustin Fitipaldi Feb 13 '19 at 20:33
  • I would recommend a decent textbook on Java. What you get is 'call a method that runs code, without bothering what that code is, or how it works', the idea is you write the code to run. 'Java the complete reference' comes to mind. Also, following the official tutorials might help: https://docs.oracle.com/javase/tutorial/ – Stultuske Feb 14 '19 at 07:40

0 Answers0