Cannot Find Symbol for another class file

后端 未结 3 1358
广开言路
广开言路 2020-12-11 11:11

I\'ve had this problem a few times, where I\'ve created another class file and the main class file can\'t find it. Here\'s the main class file:

package text         


        
相关标签:
3条回答
  • 2020-12-11 11:26

    Make sure the java files are all in the textfiles directory:

    textfiles/FileData.java
    textfiles/ReadFile.java
    

    And run:

    javac textfiles/FileData.java textfiles/ReadFile.java 
    java textfiles.FileData
    

    Your code works without any modification. I think you are compiling from a wrong directory:

    C:\Users\Liloka\Source>javac FileData.java

    Move the FileData.java to the textfiles directory.

    0 讨论(0)
  • 2020-12-11 11:40

    You have to compile all the java files used by your main class. As ReadFile is used by FileData you have to compile it too.

    Did you tried

    javac Filedata.java ReadFile.java
    

    or

    javac *.java
    

    ?

    0 讨论(0)
  • 2020-12-11 11:50

    There must be a conflict with generated classes. Just try to remove all the classes that have been generated and build project again.

    0 讨论(0)
提交回复
热议问题