1

I have a project that can be completed in any language. I wrote my project in Java. For the submission, the professor asks for a tar of our source code along with a makefile. From what I have been reading, it sounds as if it is not necessary to have a makefile for a Java program. I also understand that it is still possible to create a makefile. I have attempted to look at several samples for creating a makefile, but have run into several problems. If I were to bypass the makefile, what files would I need to include in my submission? My best guess is to include the .class file or the .xml (Ant project, I am working in NetBeans). Also, would I need to include anything else in place of the makefile?

EDIT: My attempt at creating a makefile looks like this:

JFLAGS = -g
JC = javac
#
.SUFFIXES: .java .class
.java.class:
    $(JC) $(JFLAGS) $*.java
CLASSES = \
    QuickSort.java \
default: classes
classes: $(CLASSES:.java=.class)
clean:
    $(RM) *.class

It's actual filename is Makefile.mak. I have tried a couple different ways of running it. When I just type in make in MinGW, I get "make: *** No targets specified and no makefile found. Stop." I have also tried just entering Makefile.mak. This produces a long list of commands not found.

user3068177
  • 357
  • 2
  • 5
  • 17
  • 2
    If the professor wants a makefile, not providing a makefile doesn't seem like a successful strategy. I suggest you write a makefile. – Elliott Frisch Feb 15 '16 at 02:28
  • One of my fellow classmates is writing his program in python and asks if he needed a makefile since python doesn't require one. The response from the teacher was that he doesn't really need one though it is still possible to make one. My understanding is that NetBeans in someway creates the equivalent of a makefile for me. – user3068177 Feb 15 '16 at 02:30
  • I found a good reference with a good amount of information here: http://stackoverflow.com/questions/2209827/why-is-no-one-using-make-for-java – user3068177 Feb 15 '16 at 02:47

1 Answers1

1

You could make it a lot simpler, (note that the commands are preceded by mandatory tabs below)

QuickSort.class: QuickSort.java
        javac -g QuickSort.java

clean:
        rm -f QuickSort.class
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
  • I was originally receiving a javac command not found error. I fixed that by editing my environment variables. I am still receiving a clean:: command not found and QuickSort.class :: command not found. How would I go about fixing these errors? – user3068177 Feb 15 '16 at 03:21
  • 1
    The above is makefile syntax. Place it in a file named `Makefile`. The default target is the first `QuickSort.class` (and it depends on `QuickSort.java`). – Elliott Frisch Feb 15 '16 at 03:23
  • It looks like I got it. Sorry I probably came off bit dense when trying to follow the instructions but I very much appreciate the help. – user3068177 Feb 15 '16 at 03:30
  • So would I be correct in just submitting the QuickSort.class that was generated for my makefile? – user3068177 Feb 15 '16 at 03:30
  • 1
    No. Create a tar file of the Makefile and the java source file (`tar cf MyProject.tar Makefile QuickSort.java`). You could include `QuickSort.class`, but I believe the point of the exercise is your professor intends to build it and run it. – Elliott Frisch Feb 15 '16 at 03:32
  • Sorry, that is what I was trying to ask. To clarify, when he says include the makefile in the tar, the make file in this case is the QuickSort.class? – user3068177 Feb 15 '16 at 03:34
  • 1
    No. It's the file `Makefile` (the command make uses a make file **named** `Makefile`). You also need the source file. See my example `tar` command. It includes `Makefile` and `QuickSort.java` in `MyProject.tar`, which is (I believe) what you are being asked to do. – Elliott Frisch Feb 15 '16 at 03:35