aspose file tools*
The moose likes Java in General and the fly likes Running jars from a java application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running jars from a java application" Watch "Running jars from a java application" New topic
Author

Running jars from a java application

Naresh Rajan
Ranch Hand

Joined: Sep 08, 2005
Posts: 45
Hi,
I have a java application that should run other jars. For example

I have JAR1, JAR2, JAR3. Each jar has a batch process BAT1, BAT2,BAT3. My application will call each of these batch processes. Once BAT1 is finished BAT2 should be called and so on. How am I supposed to do this?

Another complication is that the application is tested on windows and then will be deployed on Linux during production. So i will be using shell there but still i should be making as little changes as possible to my installable

Please help me in this regard

Regards,


Am not a pro and thats why am here!!!
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3679
    
  16
Use Runtime.exec() to run your script/batch.
If you need to run different commands on different operating systems, then use System.getProperty("os.name") to find out what OS you are running on.


Joanne
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

What are you doing in those batch-Processes?
Can't you do it purely in java?

That would be much better maintainable for different plattforms.


http://home.arcor.de/hirnstrom/bewerbung
Naresh Rajan
Ranch Hand

Joined: Sep 08, 2005
Posts: 45
In continuation to the above thread.......

I will be running the Java application on AIX and the jars will have to be run using shell scripts. Java Docs say that execute() doesn't work properly for the shell scripts.

So what am I suposed to do in this case. Can't I run shell scripts from java???

Regards
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3679
    
  16
Can you post a link to the JavaDoc that says that exec() (I assume that's the method you meant) doesn't work properly for shell scripts.
Vivek Raman
Greenhorn

Joined: Nov 14, 2005
Posts: 2
if u want to execute some commands (Windows based) try giving the following code

the executeScript.bat can be built in runtime or before.

If you want to execute a single DOS command then try the following

Hope it helps.


-------------------<br /> SCJP 1.4 SCBCD1.3<br />-------------------
Naresh Rajan
Ranch Hand

Joined: Sep 08, 2005
Posts: 45
HI Joanne,

the link given below says what i had quoted.

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Process.html
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3679
    
  16
It says shell scripts MAY not work. Have you actually tried your scripts or are you just assuming they won't work.
If they don't work then, then I would repeat Stefan's earlier question. Can't you do whatever these scripts are doing directly in Java ?
Naresh Rajan
Ranch Hand

Joined: Sep 08, 2005
Posts: 45
Joanne

will have to try. will do that.

as for the second question. the different jars may have different changes in the future course of time. and if i have one single jar testing process will become complicated.

instead of using a java application i am thinking of using shell script.

regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running jars from a java application