-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartSimulation.sh
More file actions
executable file
·34 lines (28 loc) · 1.15 KB
/
startSimulation.sh
File metadata and controls
executable file
·34 lines (28 loc) · 1.15 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
#!/bin/bash
program_name="Satogaeri";
main_class_java_path="main.Main";
main_class_file_path="src/main/Main.java";
source_folder="src";
output_folder="build";
if ! type javac > /dev/null 2>&1; then
printf "error: No Java installation was found! Make sure Java 8 or newer is installed correctly\n" >&2;
printf "error: and visible inside your PATH variable.\n" >&2;
exit 2;
fi
if [ -f "${main_class_file_path}" ]; then
printf "[%s]: Compiling Java sources ...\n" "${program_name}";
javac -d "${output_folder}" -classpath "${source_folder}" "${main_class_file_path}";
if [ $? -eq 0 ]; then
printf "[%s]: Compiled bytecode was moved to '%s' folder.\n\n" "${program_name}" "${output_folder}";
printf "[%s]: Executing %s\n" "${program_name}" "${program_name}";
java -classpath "${source_folder}:${output_folder}" "${main_class_java_path}";
exit $?;
else
printf "[%s]: Failed to compile the Java sources! Exiting ...\n";
exit 1;
fi
else
printf "error: You are not in the correct root directory. Please execute this script from\n" >&2;
printf "error: %s\n" "$(dirname "$0")" >&2;
exit 2;
fi