Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I have pieces of code, written in java, which I can convert in jar and run from the terminal.

I also have some node.js script, which I would like to run before running these jar files.

So the process of running my project is as follows:

Start mongodb from terminal->Run Node.js script-> Run the java code(jar file)

So I want to know, is there a way I could automate my project by just calling some one single file instead of running so many files separately? if so, how?

share|improve this question

closed as off-topic by Scant Roger, GlenH7, Ixrec Nov 23 at 18:38

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to find or recommend tools, libraries, programming languages, resources (including books, blogs, tutorials, and examples), or projects to undertake are off-topic on Programmers as they attract opinionated answers that won't have lasting value to others. You may be able to get help in The Whiteboard, our chat room." – Scant Roger, GlenH7, Ixrec
If this question can be reworded to fit the rules in the help center, please edit the question.

Ant. – Florian Margaine Jan 22 '13 at 11:15
That's Unix or Windows? Shell script would be an option. Just type the commands into a textfile, name it .sh and you can execute it from Bash terminal. – thorsten müller Jan 22 '13 at 11:17
@thorstenmüller I use mac osx. – spaniard89 Jan 22 '13 at 11:17
@FlorianMargaine That's too complicated. And I even doubt if it could ren node.js scripts. – spaniard89 Jan 22 '13 at 11:18
@spaniard89 Ant is the tool used for anyone using Java. You should definitely learn how to use it, at least. And yes, it can run node.js scripts. – Florian Margaine Jan 22 '13 at 11:19

1 Answer 1

up vote 2 down vote accepted

Expanding Florian's comment, Ant would probably be your best bet.

There's a decent example and explanation here. My advice to you would be to try to understand how it works, instead of just hastily modifying it to suit your needs. Ant is incredibly powerful to those who use it right.

You can call it from the command line. The ant package also comes with a bin folder containing both a batch file and a shell script to call ant in a convenient fashion:

ant -buildfile <name of build file.xml goes here> <task name>

It has the added advantage that like Java, it is platform independent and makes the difficulty of adapting it to new platforms as trivial as creating a shell script or batch file that calls it.

share|improve this answer
Thanks for that! I will look into it. – spaniard89 Jan 22 '13 at 11:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.