/
Compile Java File(s)
executable file
·30 lines (28 loc) · 1.38 KB
/
Compile Java File(s)
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
#!/usr/bin/env bash
# Code Developed By: Rushyang Darji
# Initial Build: 29.03.2011
# Last Updated: 23.04.2011
# Prerequisites: zenity, JDK.
# I created this script when I was working on servlets & I found myself very lazy to go into terminal and compile everytime.
# ~/.source4servlet file contains the commands to export the environment variable for JAVA_HOME, JRE_HOME & CLASSPATH
source "/home/rushyang/.source4servlet"
temp=$(mktemp)
trap "rm $temp" 0 1 2
if [[ ! -z $NAUTILUS_SCRIPT_SELECTED_URIS ]]; then
for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
base=`basename "$uri"`
javac "$base" 2> $temp | zenity --progress --pulsate --auto-close --text="Compiling..." --title="$base" --width=250 --height=125
[[ -s "$temp" ]] && zenity --text-info --filename="$temp" --title="Error log for $base" --width=600 --height=600
done
else
#Making array of jfiles, containing all java files name inside it
jfiles=()
while read -r -d $'\0'; do
jfiles+=("$REPLY")
done < <(find . -maxdepth 1 -print0 -name "*.java")
[[ -z "$jfiles" ]] && zenity --error --text="No Java files were found in current working directory!" --no-wrap && exit
for i in *.java; do
javac "$i" 2> $temp | zenity --progress --pulsate --auto-close --text="Compiling..." --title="$i" --width=250 --height=125
[[ -s "$temp" ]] && zenity --text-info --filename="$temp" --title="Error log for $i" --width=600 --height=600
done
fi