Java error - bad source file: file does not contain class x . Please remove or make sure it appears

后端 未结 5 1363
你的背包
你的背包 2020-11-30 12:36

Recently started studying Java for an exam.

While learning packages, tried this and got an error message. What I did was,




        
5条回答
  •  渐次进展
    2020-11-30 13:17

    move the A.java under folder JavaTest to com/test/helpers. the error you are seeing is for the compiler complaining that A.java is in a folder that does not match its package declaration. Remember, you cannot access A from App without A being in a package.

    from under src driectory run the following command to compile your classes

    src> javac ./*.java ./com/test/helpers/*.java
    

    then from under src folder

    src>java App
    

    that should run your program.

提交回复
热议问题