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=.clas开发者_JAVA百科s)
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!
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?
精彩评论