user1670032
user1670032

Reputation: 770

MakeFile for Java?

I've looked at several questions and read through a couple of tutorials but MakeFile is still a bit of a confusing concept to me.

From what I understand, it is essentially a set of rules for building up Unix commands to compile and run the code?

So far, I have been just running my Unix commands as such:

>> javac Main.java SomeClass1.java SomeClass2.java
>> java Main input_file.txt

because my Main function takes in an input_file.

I want to be able to make this more efficient by using Make, but I am having trouble with understanding the concepts.

Any help is much appreciated!

Thank you!

Upvotes: 1

Views: 446

Answers (1)

Jesper
Jesper

Reputation: 207026

Make is a build tool - a piece of software to compile the source code of software projects into an executable.

When you are creating small, simple programs, you don't really need a build tool. You can just compile your code by running the compiler javac on the command line. But when you start working on a larger project with many source files, it's going to be too cumbersome to compile all the source files by hand. You'll want to use a build tool. Besides compiling your code, a build tool can help you perform other tasks, such as automatically running unit tests and automatically managing dependencies (libraries that your program needs).

For a Java project, consider using a Java build tool such as Apache Ant, Apache Maven or Gradle. Those are the de-facto standard build tools for Java projects, and the big Java IDEs (Eclipse, IntelliJ and NetBeans) have support for these tools.

Make is mainly used for C and C++ projects and is not very well suited for Java.

Upvotes: 3

Related Questions