Skip to content

Instantly share code, notes, and snippets.

@InterestingBrainPoops
Created August 31, 2020 17:14
Show Gist options
  • Save InterestingBrainPoops/826f45bcc52b3aa3871b1d36fdb1b93b to your computer and use it in GitHub Desktop.
Save InterestingBrainPoops/826f45bcc52b3aa3871b1d36fdb1b93b to your computer and use it in GitHub Desktop.
Java project Builder and executor.
#!/bin/bash
bin/mkdir -p /tmp/.java/classes 2> /dev/null
# Compile the program.
#
javac -d /tmp/.java/classes $0
# Run the compiled program only if compilation succeeds.
#
[[ $? -eq 0 ]] && java -cp /tmp/.java/classes $(basename ${0%.*}) "$@"
exit

Usage

All you have top do is just write this:

bash Beep.sh Filename.java

that will then Compile and run the program without any other class files being generated.
They will be generated but they will be pushed to the /tmp/.java/classes Directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment