Christopher Schroeder
Christopher Schroeder

Reputation: 35

How do I add a .jar file to the compilation of .java files

My makefile is below

Also, I would appreciate it if you told me how to move my .class files to ../bin/

JFLAGS = -cp
JAR = "RSBot*.jar"
JC = javac
.SUFFIXES: .java .class
.java.class:
                $(JC) $(JFLAGS) $(JAR) $*.java

CLASSES = \
                src/Banker.java \
                src/Eater.java \
                src/Fighter.java \
                src/grotgui.java \
                src/InventTab.java \
                src/Looter.java \
                src/Potter.java \
                src/W8babyGrotworm.java \
                src/Walker.java

default: classes

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

clean:
                $(RM) *.class

Upvotes: 3

Views: 2885

Answers (2)

Matt
Matt

Reputation: 11815

just out of curiosity, why make? why not use a more modern tool like maven, ant or gradle?

They are designed for this sort of thing and usually give you what you want out of the box.

But to answer your question:

javac -d outputdir

Upvotes: 0

jalopaba
jalopaba

Reputation: 8129

As you can see here, How to wildcard include JAR files when compiling?, you cannot use the wildcard '*' in the classpath to get several jar files unless you are using java 1.6 or above. Otherwise, you should write each concrete jar you need.

To put your .class files in the bin directory, you can use the -d <directory> option of javac to specify where to place generated class files.

Upvotes: 2

Related Questions