Question: How do I compile and run a program in Java on my mac? 

I'm new.

Also I downloaded a program that was suggested to me on here called text wrangler if that has any bearing on the situation.

Answer: 
You need to make sure that a mac compatible version of java exists on your computer. Do java -version from terminal to check that. If not, download the apple jdk from the apple website. (Sun doesn't make one for apple themselves, IIRC.)

From there, follow the same command line instructions from compiling your program that you would use for java on any other platform.
Other solutions are good enough to answer your query. However, if you are looking for just one command to do that for you - 

Create a file name "run", in directory where your Java files are. And save this in your file -

```
javac "$1.java"
if [ $? -eq 0 ]; then
  echo "--------Run output-------"
  java "$1"
fi

```

give this file run permission by running -

```
chmod 777 

```

Now you can run any of your files by merely running - 

```
./run <yourfilename> (don't add .java in filename)

```