Thursday, August 25, 2011

Run Java main method from a shell script

Following is a shell script, which runs a Java class 'Example' accepting one argument. Further it puts the required libraries and configuration files to the class path.

#!/bin/bash
_CP=../conf/

for i in ../lib/* ; do
    if [ "$_CP" != "" ]; then
          _CP=${_CP}:$i
    else
         _CP=$i
    fi

done

for i in ../conf/*.* ; do
    if [ "$_CP" != "" ]; then
          _CP=${_CP}:$i
    else
         _CP=$i
    fi

done

    echo "running ...... "

    echo "--------------------------------------------------------"
    java -Xms64m -Xmx254m -cp $_CP:. com.shyarmal.Example $1


thanks,
Shyarmal.

No comments:

Post a Comment