You are not logged in.
Pages: 1
Hello all,
After a year of linux, I've officially converted my desktop to Arch (best idea of 2008). I've switched all my Java coding from JCreator to Vim and command line operations.
I read everything I could find about bash and created this:
#!/bin/bash
COMPILE=""
echo
for file in *.java
do
CLASS=`echo ${file%.java}`.class
if [ ! -e $CLASS ] || [ $file -nt $CLASS ] ; then
echo " > $file"
COMPILE+=" $file"
fi
done
if [ -n "$END" ] ; then
echo
echo "Compiling files . . ."
javac $COMPILE
else
echo "No compililation needed"
fi
echo
java GUI
I intend to compile only recently edited *.java files. It first checks for a *.class file, then checks the file's mtime. I ended the script with "java GUI" to run and test my project.
My questions is:
How do I check javac output for errors? I don't want to run "java GUI" if errors exist.
I know that I can save the sterr output with:
javac *.java 2> error.log
or
javac -Xstdout error.log *.java
So, how do I add a check for errors?
Could it be done without creating a log file?
Thanks in advance,
JT
Offline
What's wrong with Ant?
Offline
In a Bash script, $? expands to the exit code of the last command. The convention is to exit 0 for success; any other number indicates some error.
some_command_here
if [ $? -eq 0 ]; then
echo "Exited successfully!"
else
echo "OMFG! ERROR!"
fi
M*cr*s*ft: Who needs quality when you have marketing?
Offline
Perfect, thank you.
Offline
Pages: 1