简体   繁体   English

Eclipse源代码错误

[英]Eclipse Source Code Error

while I was studying Stanford CS 106 AI had to download acm.jar file. 在我学习斯坦福CS 106 AI时,必须下载acm.jar文件。 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: 错误向下:

在此处输入图片说明

( http://i.imgur.com/5NcUj2S.png?1 ) http://i.imgur.com/5NcUj2S.png?1

When I want to run: 当我想跑步时:

http://imgur.com/E042rHs http://imgur.com/E042rHs

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. 我在演讲5。

Your javafile is not in your sources directory and hence not on your build-path. 您的javafile不在您的sources目录中,因此不在您的构建路径中。

Try moving Add2Doubles.java to your src folder. 尝试将Add2Doubles.java移动到src文件夹。

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). 编辑:感谢评论,我想到了另一个建议:您可能还必须将acm目录也移动到src文件夹(实际上,这是eclipse在其中查找源文件的位置)。

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. 我相信URLClassLoader是默认Java运行时库的一部分,因此您需要从Java网站获取源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM