rainman
rainman

Reputation: 2649

Cannot find symbol error while compiling java class from the command line

I want to compile a java class called Contrat.java which is using an object of the class ListContrat.java both classes are located in the same folder whose path is : C:\Users\hue7\workspace\Test\src\com\sky, I tried to compile (create .class) executing the following commands from the folder namded sky:

javac Contrat.java and javac -cp ListContrat.java Contrat.java both gives the error:

    Contrat.java:21: error: cannot find symbol 
        protected List<ListContrat> contrat; 
                       ^ 
  symbol:   class ListContrat 
  location: class Contrat 
Contrat.java:23: error: cannot find symbol 
        public List<ListContrat> getContrat() { 
                    ^ 
  symbol:   class ListContrat 
  location: class Contrat 
Note: Contrat.java uses unchecked or unsafe operations. 
Note: Recompile with -Xlint:unchecked for details. 
2 errors 

But when I execute the command javac Contrat.java from src folder it works correctly.

Can anyone explain why please ?

Upvotes: 1

Views: 97

Answers (1)

rainman
rainman

Reputation: 2649

Finally I resolved the error, executing the command from the src folder.

Upvotes: 1

Related Questions