This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Detecting java , ant script needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Detecting java , ant script needed" Watch "Detecting java , ant script needed" New topic
Author

Detecting java , ant script needed

Jas Oberai
Ranch Hand

Joined: Jan 16, 2005
Posts: 231
Hi Friends,
I have a ant based installer. Now,I want to write an ant script that should detect if java is already installed on the system or not.If not, it should try to install java that is there with the installer package.
So,any help as to how to accomplish this??
Thanks


SCJP 1.4 (88%)<br />SCWCD 1.4 (88%)
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
Since Ant needs Java to run, it would be quite a miracle to get it to install Java if it isn't installed already
Jas Oberai
Ranch Hand

Joined: Jan 16, 2005
Posts: 231
Thanks for your reply.I can try some other way to detect java for eg, I could run a batch script to start with,that should check to see if java is there or not.

If yes,launches the ant installer otherwise starts java installation.

Is that feasible?Any help on that??
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17030
    
  26

Unix/Linux:

java -version >/dev/null || install-java.sh

Of course, if Java isn't installed, you probably didn't have an install-java sehll script either.


An IDE is no substitute for an Intelligent Developer.
 
Have you checked out Aspose?
 
subject: Detecting java , ant script needed
 
It's not a secret anymore!