# Java on Apple Machines

**URL:** <https://boards.straightdope.com/t/java-on-apple-machines/472637>\
**Category:** Factual Questions\
**Created:** [November 14, 2008, 12:53am UTC](https://boards.straightdope.com/t/java-on-apple-machines/472637 "2008-11-14T00:53:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![uznuS](https://avatars.discourse-cdn.com/v4/letter/u/b2d939/32.png) [@uznuS](https://boards.straightdope.com/u/uznuS)\
**Post date:** [November 14, 2008, 12:53am UTC](https://boards.straightdope.com/t/java-on-apple-machines/472637/1 "2008-11-14T00:53:24Z")

</div>

I am stuck trying to figure out what to do with a .java program on my mac. If I open up the file in a text editor, I can see the source code. Does this mean that the file needs to be compiled or do macs have a java compiler built-in?

thanks!

---

<div class="post-metadata">

**Author:** ![RaftPeople](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@RaftPeople](https://boards.straightdope.com/u/RaftPeople)\
**Post date:** [November 14, 2008, 12:56am UTC](https://boards.straightdope.com/t/java-on-apple-machines/472637/2 "2008-11-14T00:56:38Z")

</div>

I can’t speak to Mac, but every other platform I’ve coded Java on (Windows, AS400, Sun) you had to run a .java file through the javac compiler.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [November 14, 2008, 12:58am UTC](https://boards.straightdope.com/t/java-on-apple-machines/472637/3 "2008-11-14T00:58:03Z")

</div>

Java is pretty platform agnostic, so I would assume that yes, you need to compile it.

---

<div class="post-metadata">

**Author:** ![King\_Solomon\_Hill](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@King\_Solomon\_Hill](https://boards.straightdope.com/u/King_Solomon_Hill)\
**Post date:** [November 14, 2008, 1:50am UTC](https://boards.straightdope.com/t/java-on-apple-machines/472637/4 "2008-11-14T01:50:24Z")

</div>

OS X kind of has a Java compiler built in.  
Xcode can compile Java programs, it come free with OS X but isn’t always in the standard install.  
You should be able to install it from your original OS X cd’s if you have them.

I’ve no idea how much experience you have when it come to Java, but be aware that although it’s supposed to be platorm independent, compilng a Java program designed for another system isn’t always straightforward.

---

<div class="post-metadata">

**Author:** ![Flymaster](https://avatars.discourse-cdn.com/v4/letter/f/c4cdca/32.png) [@Flymaster](https://boards.straightdope.com/u/Flymaster)\
**Post date:** [November 14, 2008, 1:55am UTC](https://boards.straightdope.com/t/java-on-apple-machines/472637/5 "2008-11-14T01:55:47Z")

</div>

If you open a terminal window, navigate to the folder with the .java file, and type javac yourfile.java, it should compile. Then type java yourfile.class and it should work. Assuming ./ is in your path. If not, replace yourfile with ./yourfile

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [November 14, 2008, 3:38am UTC](https://boards.straightdope.com/t/java-on-apple-machines/472637/6 "2008-11-14T03:38:00Z")

</div>

> [@Flymaster](#):
>
> If you open a terminal window, navigate to the folder with the .java file, and type javac yourfile.java, it should compile. Then type java yourfile.class and it should work. Assuming ./ is in your path. If not, replace yourfile with ./yourfile

Note that javac won’t be installed by default; you’ll have to install the Developer Tools package from your OS X CD’s if you haven’t already done it.

Once you’ve got that, you’ll have standard commandline compilers available for just about everything, plus XCode which is super awesome.

---

<div class="post-metadata">

**Author:** ![uznuS](https://avatars.discourse-cdn.com/v4/letter/u/b2d939/32.png) [@uznuS](https://boards.straightdope.com/u/uznuS)\
**Post date:** [November 14, 2008, 5:13am UTC](https://boards.straightdope.com/t/java-on-apple-machines/472637/7 "2008-11-14T05:13:00Z")

</div>

javac worked without having purposely installed xcode…thanks!
