Pregunta

My java project makes use of some apache commons libraries. I want to be able to run my program in unix though so i made a makefile to compile it for me. My project has 4 Java classes and 4 external libraries (.jars). In my directory i have my four .Java files and a folder named "lib" which contain my .Jar files. Here's my make file:

 JFLAGS = -g
JC = javac -sourcepath / -classpath lib/commons-httpclient-3.1.jar:lib/commons-io-2.4.jar:lib/commons-codec-1.9.jar:lib/commons-logging-1.1.3.jar
.SUFFIXES: .java .class
.java.class:
$(JC) $(JFLAGS) $*.java

CLASSES = \
SubmissionDriver.java \
FileAndArgs.java \
hashConverter.java \
InvalidAgeException.java

default: classes

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

clean:
    $(RM) *.class

And here's my error messages: I get like 14 error message that pertain to the actual class files though. Here's some examples:

SubmissionDriver.java:74: error: cannot find symbol
    public static void httpSend() throws HttpException, IOException{
                                         ^
  symbol:   class HttpException
  location: class SubmissionDriver
SubmissionDriver.java:75: error: cannot find symbol
            HostConfiguration hf=new HostConfiguration();
            ^
 symbol:   class HostConfiguration
 location: class SubmissionDriver
SubmissionDriver.java:75: error: cannot find symbol
            HostConfiguration hf=new HostConfiguration();
                                     ^
 symbol:   class HostConfiguration
 location: class SubmissionDriver
SubmissionDriver.java:77: error: cannot find symbol
            PostMethod post = new PostMethod("myurl");
            ^

Also it states this at the bottom of thsoe 14 error messages:

14 errors
make: *** [SubmissionDriver.class] Error 1
¿Fue útil?

Solución

  1. Make is not a good build tool for java. Try ant perhaps (or Maven, or Gradle)
  2. The way your makefile is structured you invoke a "javac" command for each java class. This will not work if your java classes have dependencies on each other
  3. Make sure you have a tab before this line

    $(JC) $(JFLAGS) $*.java

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top