1

while I was studying Stanford CS 106 A I had to download acm.jar file. I have imported and everything worked fine till I wanted to run a simple program from the source code I got in video. The error down below:

enter image description here

(https://i.sstatic.net/dcf9v.png)

When I want to run:

https://i.sstatic.net/evrhY.jpg

and the source code:

import acm.program.*;


    public class Add2Doubles extends ConsoleProgram {
        public void run() {
           println("This program adds two numbers.");
           int n1 = readInt("Enter n1: ");
           int n2 = readInt("Enter n2: ");
           int total = n1 + n2;
           println("The total is " + total + ".");
        }
     }

Thanks in advance for your helps. I'm on lecture 5.

1
  • For better help sooner, post an SSCCE. Note that most people won't follow links, especially if they are to YouTube. Commented Nov 16, 2013 at 12:09

2 Answers 2

1

Your javafile is not in your sources directory and hence not on your build-path.

Try moving Add2Doubles.java to your src folder.

edit: Thanks to the comment I thought about another suggestion: You might have to move your acm directory to the src folder as well (as indeed, that is where eclipse will look for your source files).

Sign up to request clarification or add additional context in comments.

2 Comments

"on your build path" is Eclipse slang for where it looks for sources to compile.
Thank you guys. As already mentioned I moved the source code and acm folder into src folder now it works.
0

The error explains it well enough to me? You've not got any sources! I believe that URLClassLoader is part of the default java runtime libraries so you can need to get the sources from the Java website.

1 Comment

Try doing what ljgw did then, also does it run correctly if you right click the java file and run it from there? Run As > Application

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.