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: 
Download and install Eclipse, and you're good to go.  

<http://www.eclipse.org/downloads/>

Apple provides its own version of Java, so make sure it's up-to-date.  

<http://developer.apple.com/java/download/>

---

Eclipse is an [integrated development environment](http://en.wikipedia.org/wiki/Integrated_development_environment). It has many features, but the ones that are relevant for you at this stage is: 

* The source code editor
	+ With syntax highlighting, colors and other visual cues
	+ Easy cross-referencing to the documentation to facilitate learning
* Compiler
	+ Run the code with one click
	+ Get notified of errors/mistakes as you go

As you gain more experience, you'll start to appreciate the rest of its rich set of features.
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)

```