#!/bin/bash # compile java program with javac # usage: # myjava xxx.java # copyright @ http://scriptdemo.blogspot.com if [ $# -eq 0 ]; then sed -n '2,4p' myjava exit else srcfile=$1 nf=`echo ${srcfile} | awk -F. '{print NF}'` if [ $nf -eq 1 ]; then exefilename=${srcfile} srcfile=${srcfilename}.java elif [ $nf -eq 2 ]; then exefilename=`echo ${srcfile} | awk -F. '{print $1}'` else myjava exit fi if [ -e ${srcfile} ]; then javac ${srcfile} java -classpath . ${exefilename} elif [ -e ${exefilename} ];then java -classpath . ${exefilename} else echo "${srcfile} can\'t be found in current directory!" exit fi fi |
Sunday, January 30, 2011
compile java program with javac
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment