脚本如下
123456789101112131415
#!/bin/bashset -efileName=$1if [ -z "$fileName" ]; then echo "Parameters error!" exit fiif [ ! -d classes ]; then mkdir classesficlassName=${fileName%%.*}javac $className.java -d ./classes/java -classpath ./classes $className
1234567
public class FinalTest{ public static void main(String[] args) { System.out.println("Hello world!"); }}
配合Tab键、↑应该可以高效地操作
1234
bogon:Java fang$ lsFinalTest.java test.shbogon:Java fang$ ./test.sh FinalTest.java Hello world!