Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions Java.crLanguage/Scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ enc[1]="ASCII" # ASCII

directory=`dirname "$0"`

originalWorkingDirectory="$PWD"
cp "$PWD/$CR_FILENAME" "$CR_TMPDIR/$CR_FILENAME"
cd "$CR_TMPDIR"

# Check if file resides in a folder with package name, if so, change directory
package=`"$CR_DEVELOPER_DIR/bin/parsejava" --package "$PWD/$CR_FILENAME" 2>/dev/null`
if [ ${#package} -ne 0 ]; then
if [ $? -eq 0 ] && [ ${#package} -ne 0 ]; then
# Check if package name is in the form package.subpackage.subpackage
# If this structure matches directory structure, change directory...
packageDirectory=`echo "$package" | sed 's/\./\//g'`
Expand All @@ -61,17 +65,6 @@ elif [ ! -z $CR_SANDBOXED ] && [ ! -r "$PWD" ]; then
cd "$tmp"
fi

javac "$CR_FILENAME" -encoding ${enc[$CR_ENCODING]} "${@:1}" ${CR_DEBUGGING:+-g}
status=$?

if [ $status -ne 0 ]; then
javac -version &>/dev/null
if [ $? -ne 0 ]; then
echo -e "\nTo run Java code, you need to install a JDK. You can download a JDK at http://oracle.com/technetwork/java/javase/downloads/\n\nIf you see a prompt asking you to install Java, it may not include the necessary components for compiling Java code. Therefore, use the link above to download and install a JDK."
fi
exit $status
fi

# Use parsejava to get package and class name of main function.
out=`"$CR_DEVELOPER_DIR/bin/parsejava" "$PWD/$CR_FILENAME" 2>/dev/null`
status=$?
Expand All @@ -85,4 +78,17 @@ if [ $status -ne 0 ]; then
fi
fi

echo "$PWD:$out"
cd "$originalWorkingDirectory";

javac "$CR_FILENAME" -encoding ${enc[$CR_ENCODING]} "${@:1}" ${CR_DEBUGGING:+-g}
status=$?

if [ $status -ne 0 ]; then
javac -version &>/dev/null
if [ $? -ne 0 ]; then
echo -e "\nTo run Java code, you need to install a JDK. You can download a JDK at http://oracle.com/technetwork/java/javase/downloads/\n\nIf you see a prompt asking you to install Java, it may not include the necessary components for compiling Java code. Therefore, use the link above to download and install a JDK."
fi
exit $status
fi

echo "$PWD:$out"