• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running jars from a java application

 
Naresh Rajan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Naresh Rajan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Naresh Rajan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic