java Makefile


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting java Makefile
# 1  
Old 10-16-2005
java Makefile

Ive been trying to write a simple Makefile to compile *.java files to *.class files that reside in different directories.

[code]
-- main_dir ----subdir1
-----subdir2
[code]

here's my Makefile. it wont run what should i do? thanks for all the help!
Code:
JAVAC = javac
JFLAGS =

SUBDIRS = main_dir subdir1 subdir2

all:
        @@for file in $(SUBDIRS); do
                 $(JAVAC) $(JFLAGS) *.java
        done

# 2  
Old 10-16-2005
If my understanding is correct, each command is taken as one single line, so you need to write the loop as if on a single line.

Maybe you try this:

Code:
JAVAC = javac
JFLAGS =

SUBDIRS = main_dir subdir1 subdir2

all:
        @@for file in $(SUBDIRS); do \
                 $(JAVAC) $(JFLAGS) *.java; \
        done

Also make sure the whitespace before the command are all real tabs.

If you still have problems running it, please don't forget to post the error message to help others help you.

Why don't you use Ant (http://ant.apache.org)?
# 3  
Old 10-16-2005
Error

we're asked to use makefile for this project.. i ran it and it gave me this error..
thanks for d help Smilie

Code:
/bin/sh: syntax error at line 1: `end of file' unexpected
make: *** [all] Error 2

# 4  
Old 10-16-2005
Did you try my given version? It works on my machine without this error. Your version had this error.
# 5  
Old 10-17-2005
This is a link I came across when I needed some info on makefiles - Java Makefile

vino
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

2. UNIX for Advanced & Expert Users

Makefile executing another Makefile first?

I have 2 libraries in 2 different directories that I build with Makefiles. library B depends on library A. If I modify a .cpp file in library A and run lib B's Makefile can I have B's makefile to automatically rebuild library A? I am now rebuilding A, followed by B... but I'd like B to... (0 Replies)
Discussion started by: wwuster
0 Replies

3. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies
Login or Register to Ask a Question