This article address the how to run java program/project from unix shell script. If you have jar files and those jar files path and classpath execution stuff are explained in this below shell script.Below script will help you to run java program in any location.
Replace red color text with your content.
Replace red color text with your content.
Here is the script used to run java project
#!/bin/sh
#- Main Base directories
chmod 777 thisshellscriptname.sh
echo "******* Enter your tool or project title *********"
# If you want some input from user
echo 'Enter Java Location************'
# or
# if you want java location
read varname
# Base dir path here (where your related jar files are located)
BASE_DIR="type path here"
#- Main .jar files
YOUR_JAR={BASE_DIR}/lib/YOUR_JARFILE.jar"
#- java
JAVA_EXECUTABLE="/usr/java/bin/java"
JAVA_HOME=`dirname /usr/java/bin/java`"/.."
#- main classpath
YOURCLASSPATH=.:${YOUR_JAR}
#- launching command
echo '**************YOUR TOOL NAME *************'
/usr/jdk1.5.0/bin/java -cp $YOURCLASSPATH MainClassFileName
# or
$varnamejava -cp $YOURCLASSPATH MainClassFileName
echo 'Successfully *****'
exit 0
0 Comments:
Post a Comment