-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuetjava
More file actions
executable file
·99 lines (84 loc) · 1.5 KB
/
uetjava
File metadata and controls
executable file
·99 lines (84 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
onefile(){
filepath=$2
classname=$(basename "$filepath")
if [ -z "$3" ]
then
classname="${classname%.*}"
else
if [ $3 = "-a" ]; then
args=("${@:4}")
classname="${classname%.*}"
else
classname=$3
args=("${@:5}")
fi
fi
echo "----------------------------------"
if [ ${#filepath} -eq 0 ]
then
echo "Error: No file input"
else
javac $filepath
cd $(dirname "$filepath")
java $classname $args
fi
echo
echo "----------------------------------"
echo "Process exited! Done."
}
multifile(){
if [ $4 = "-a" ]; then
args=("${@:5}")
fi
projectpath=$2
classname=$3
class=$classname
OIFS="$IFS"
IFS='.' array=($class)
IFS="$OIFS"
pathlength=${#array[*]}
i=${0}
subpath=""
for (( i=0; i < $pathlength-1; i++ )); do
subpath=${subpath}${array[i]}"/";
done
cd $projectpath
echo "----------------------------------"
if [ -z "$2" ]
then
echo "Error: No class input"
echo "----------------------------------"
exit
fi
if [ -z "$1" ]
then
echo "Error: No file input"
echo "----------------------------------"
exit
fi
javac -sourcepath . ${subpath}/*.java
java -classpath . $classname $args
echo
echo "----------------------------------"
echo "Process exited! Done."
}
while getopts ":fpa:" opt; do
case $opt in
f)
onefile $@
;;
p)
multifile $@
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
shift "$(($OPTIND -1))"