tags:

views:

33

answers:

1

Hello I am new in Java development. I tried to write a makefile which should be runnable in Linux:

JFLAGS = -g

JC = javac

.SUFFIXES: .java .class

.java.class:

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



Heap.class: FibonacciHeap.java \
    FileOperation.java \
    MinLeftistTree.java \
    RandomPermutation.java \
   Heap.java 
default: classes
classes: $(CLASSES:.java=.class)
clean:

 $(RM) *.class

In my assumption, Heap.class should be dependent on all the other java file. Also, the main file should be in it as well.

However, I cannot get it run, it shows

    Heap.java:3: package heap.FibonacciHeap does not exist

and cannot find the other reference from other java file, such as

Heap.java:61: cannot find symbol symbol  : variable RandomPermutation location: class heap.Heap
       list = RandomPermutation.GetList(listnum[route]);

This program runs fine in eclipse. Do you have any suggestions?

I am new and I might commit some mistake....and I don't know much about compiler and make file. If you can point it out I will be grateful!

A: 

I don't see where you set CLASSPATH. I don't care that it's a make file or Ant - javac.exe and java.exe expect the CLASSPATH to be set when they run. Where's yours?

I believe you have to set CLASSPATH in the makefile, before you run javac.exe.

I'd forget about make (and Eclipse) for a moment. Can you make this project compile and run in a command shell? If you can't, I'd say that you should not be leaning on any tools to help you.

Reading this might be helpful.

Is make really a requirement for fulfilling this assignment? How will the professor know that you used Eclipse or make or Ant or command shell to compile your .java to .class files?

duffymo
Thank you very much for your quick answer first. Do I need to include the set CLASSPATH in the make file or in my java source file? Do you have any other document reference which can help me?
Seen
@Seen - The CLASSPATH is a system environment variable that needs to be set before you run your program, or as you run you program with the `-cp` argument. Just type `java -help` in your terminal.
Jeremy
I will try to find a way to see if I can put the environmental variable of classpath into the make file. Thanks again for you update.
Seen