Java编译错误:找不到符号(擦除读取)

Java编译错误:找不到符号(擦除读取),java,compilation,symbols,Java,Compilation,Symbols,Java新手,从模板开始工作。知道怎么了吗?我正在使用Netbeans IDE并将java文件上传到linux机器上,我正在那里编译 PasswordField.java:42: cannot find symbol symbol : class EraserThread location: class PasswordField EraserThread et = new EraserThread(prompt); ^ PasswordField.java:42: cannot fi

Java新手,从模板开始工作。知道怎么了吗?我正在使用Netbeans IDE并将java文件上传到linux机器上,我正在那里编译

PasswordField.java:42: cannot find symbol
symbol  : class EraserThread
location: class PasswordField
  EraserThread et = new EraserThread(prompt);
  ^
PasswordField.java:42: cannot find symbol
symbol  : class EraserThread
location: class PasswordField
  EraserThread et = new EraserThread(prompt);
                        ^
2 errors

您需要首先创建(或复制)橡皮擦读取类。这是代码。您需要转到项目资源管理器,在创建上述类的同一个包中创建一个名为“橡皮擦读取”的新类。然后将其粘贴到类中:

import java.awt.event.KeyListener;
import java.io.*;

public class EraserThread implements Runnable {
    private boolean stop;

    /**
    *@param The prompt displayed to the user
    */
    public EraserThread(String prompt) {
        System.out.print(prompt);
    }

    /**
    * Begin masking...display asterisks (*)
    */
    public void run () {
        stop = true;
        while (stop) {
            System.out.print("/010*");
            try {
                Thread.currentThread().sleep(1);
            } catch(InterruptedException ie) {
                ie.printStackTrace();
            }
        }
    }

    /**
    * Instruct the thread to stop masking
    */
    public void stopMasking() {
        this.stop = false;
    }
}
一旦创建了类,就应该能够运行代码

代码来源:

编辑:
我不确定这个类是否已经存在于其他地方。您可能可以导入它而不创建它,但我不确定。只需自己创建这个类,您就可以了,不必通过代码导入它。

那么声明的
EraserThread
类在哪里?导入EraserThread类..对不起,我对这个很陌生,但这是一个在网上找到的模板,我得到的错误是它找不到类…我只是应该创建一个空的橡皮擦阅读类吗?模板就是这样给出的。如果您可以依赖Java 6或更高版本,请不要使用此橡皮擦读取乱码,如果您在输入密码时意外地让程序运行(而不是键入任何内容),这将消耗您所有的CPU。使用代替不该类不存在,非常感谢!java新手,只使用PHP。谢谢!!!!嗨,我刚开始加课。虽然我没有收到错误,我确实收到了2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010/2010*/010*/010*/010*/010*/010*/010*I'我不太确定System.out.println(“/010*”)是做什么用的,我希望其他人能了解到这一点。我自己没上过这门课,只是偶尔上一两次。
import java.awt.event.KeyListener;
import java.io.*;

public class EraserThread implements Runnable {
    private boolean stop;

    /**
    *@param The prompt displayed to the user
    */
    public EraserThread(String prompt) {
        System.out.print(prompt);
    }

    /**
    * Begin masking...display asterisks (*)
    */
    public void run () {
        stop = true;
        while (stop) {
            System.out.print("/010*");
            try {
                Thread.currentThread().sleep(1);
            } catch(InterruptedException ie) {
                ie.printStackTrace();
            }
        }
    }

    /**
    * Instruct the thread to stop masking
    */
    public void stopMasking() {
        this.stop = false;
    }
}