easy compilation of a package tree?

F

flupke

Hi,

i've created my own package and put the source tree under sources.
(i'm using windows)
Then i run a bat file with this content
dir sources /s /b /a -D *.java > srcfiles.txt
javac -d classes -cp
..;"..\lib\log4j-1.2.8.jar";"..\lib\dom4j-1.5-beta-2.jar" @srcfiles.txt

I then end up with a classes dir that i can use to make a jar.
Is there a better way of doing this? At home i also run linux so the dir
sollution
will not work. Is there another way of easily doing this?
Is suspect that i can also use ant to do this?

Thanks
 
D

Danny Woods

flupke said:
i've created my own package and put the source tree under sources.
(i'm using windows)
Then i run a bat file with this content
dir sources /s /b /a -D *.java > srcfiles.txt
javac -d classes -cp
.;"..\lib\log4j-1.2.8.jar";"..\lib\dom4j-1.5-beta-2.jar" @srcfiles.txt

I then end up with a classes dir that i can use to make a jar.
Is there a better way of doing this? At home i also run linux so the dir
sollution
will not work. Is there another way of easily doing this?
Is suspect that i can also use ant to do this?

Have you looked at Apache's Ant build tool?

http://ant.apache.org

Danny.
 
L

lyallex

Hi,

i've created my own package and put the source tree under sources.
(i'm using windows)
Then i run a bat file with this content
dir sources /s /b /a -D *.java > srcfiles.txt
javac -d classes -cp
.;"..\lib\log4j-1.2.8.jar";"..\lib\dom4j-1.5-beta-2.jar" @srcfiles.txt

I then end up with a classes dir that i can use to make a jar.
Is there a better way of doing this? At home i also run linux so the dir
sollution
will not work. Is there another way of easily doing this?
Is suspect that i can also use ant to do this?

Thanks

Oh yes, you NEED ant for this.

using ant it's as simple as telling ant where the source directory is
and where the destination directory is and then using the javac task
to get things done

Along with some scaffolding this is all you need to do what your batch
file is doing

<target name="compile" >
<javac srcdir="${src}" destdir="${dest}" >
<classpath>
<pathelement location="..\lib\log4j.jar"/>
<pathelement location="..\lib\dom4j-1.5-beta-2.jar"/>
<!-- etc etc -->
</classpath>
</javac>
</target>

Check out the jar task as well

I couldn't even begin to imagine life without ant now.
Go get it, it will transform your life.

Rgds
Lyall



"Process- How will the work and the team be organized?
The team needs to fit the culture in which it will operate,
but you should write software well rather than preserve the
irrationality of an enclosing culture" - Kent Beck
 
S

Sudsy

lyallex wrote:
I couldn't even begin to imagine life without ant now.
Go get it, it will transform your life.

I whole-heartedly agree! Ant has even replaced shell scripts
for my *NIX backups. It's a powerful tool which should find
a place in everyone's arsenal.
 
J

Jacob

flupke said:
Hi,

i've created my own package and put the source tree under sources.
(i'm using windows)
Then i run a bat file with this content
dir sources /s /b /a -D *.java > srcfiles.txt
javac -d classes -cp
.;"..\lib\log4j-1.2.8.jar";"..\lib\dom4j-1.5-beta-2.jar" @srcfiles.txt

I then end up with a classes dir that i can use to make a jar.
Is there a better way of doing this? At home i also run linux so the dir
sollution
will not work. Is there another way of easily doing this?
Is suspect that i can also use ant to do this?

Ant is an option.
Many prefer make: http://geosoft.no/javamake.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,130
Latest member
MitchellTe
Top