Monday, January 18, 2010

How to Run Java Program in Unix


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.


      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

Bookmark and Share
Hihera.com
Increase Page Rank Google
TopBlogDir.blogspot.com button
Best Indian websites ranking
Tips for New Bloggers
TopOfBlogs
The Link Exchange - Your ultimate resource for link exchange!

About This Blog

TopOfBlogs

FEEDJIT Live Traffic Feed

  © Blogger template Webnolia by Ourblogtemplates.com 2009

Back to TOP