"error: cannot find symbol" while compiling java project using makefile

Pra Sys
Pra Sys used Ask the Experts™
on
I have a simple java project with 4 java classes. I am trying to compile it using make for research purpose. All java files are placed under Test/MyProj directory and makefile is also there. Below is my makefile -

JFLAGS = -g -cp .
JC = javac
.SUFFIXES: .java .class
.java.class:
	$(JC) $(JFLAGS) $*.java

CLASSES = \
	Way.java \
	Sport.java \
	SportTester.java \
	Area.java 

default: classes

classes: $(CLASSES:.java=.class)

%.class : %.java
	$(JC) $(JFLAGS) $<

clean:
	$(RM) *.class

Open in new window


This is the error I am getting after running make. I have set javac correctly in PATH variable. If I run javac *.java from the same command prompt it works fine. What could be the problem?

C:\Test\MyProj>make
javac -g -cp . Way.java
javac -g -cp . Sport.java
Sport.java:10: error: cannot find symbol
        private Place currPlace;
                ^
  symbol:   class Area
  location: class Sport
Sport.java:11: error: cannot find symbol
        private Vector<Area> vecAreas;
                       ^
  symbol:   class Area
  location: class Sport
Sport.java:52: error: cannot find symbol
        void setCurrArea(Area p) {
                          ^
  symbol:   class Area
  location: class Sport
Sport.java:15: error: cannot find symbol
                vecAreas = new Vector<Area>();
                                       ^
  symbol:   class Area
  location: class Sport
Sport.java:16: error: cannot find symbol
                currArea = new Area("Andheri");
                                ^
  symbol:   class Area
  location: class Sport
Sport.java:27: error: cannot find symbol
        Iterator<Area> itr = vecAreas.iterator();
                 ^
  symbol:   class Area
  location: class Sport
Sport.java:45: error: cannot find symbol
                Area pl = new Area(p);
                ^
  symbol:   class Area
  location: class Sport
Sport.java:45: error: cannot find symbol
                Area pl = new Area(p);
                               ^
  symbol:   class Area
  location: class Sport
8 errors
make: *** [Sport.class] Error 1

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
The Java compiler can also be more efficient by caching the compiled results of other classes while compiling further classes that depend on the results of ones already compiled. This sort of automatic dependency evaluation is not really possible with make alone.

from THIS
You have dependency problems probably because they are being compiled in the wrong order. A glob might be better but make is the wrong tool for the job
Pra SysSoftware Professional

Author

Commented:
I changed makefile as below and it worked.

%.class : %.java
      $(JC) $(JFLAGS) *.java
Software Professional
Commented:
I changed makefile as below and it worked.

%.class : %.java
      $(JC) $(JFLAGS) *.java
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Top Expert 2016
Commented:
... which is what i suggested:
A glob might be better
Pra SysSoftware Professional

Author

Commented:
Sorry. I missed that part in your reply. Have indicated your reply as a solution now. Appreciate your help.
Top Expert 2016

Commented:
np :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial