![](/uploads/1/2/6/6/126629689/793583872.jpg)
Mac comes with the JDK pre installed most of the time. And it is going to be run through a command line with the command javac to compile and then java to run iirc.
![Text Text](http://i.stack.imgur.com/jqDWu.png)
Jan 21, 2017 This video will show you how to write a simple java program in sublime text 2 normally a text editor, and its compilation and execution on Mac Terminal with detailed Steps.is provided in the.
![Java Java](/uploads/1/2/6/6/126629689/720361730.png)
I use a Mac to write and compile my java code.You are going to want to get a third party program such as.text wrangler which was much better for Perl.Astro for Java (my personal favorite).Eclipse if you have the time to get it to workHope this helped if you need any more help feel free to pm me with questions I will answer to the best of my ability.
#!/bin/bash # compiles all java files within directory and runs first argument for file in.javado echo 'Compiling $file 'javac $file donegnome-terminal -e 'bash -c 'java $1; echo 'Press ENTER to quit.' ; read line $The running of program in Sublime's console was buggy. I tried to mess around with it. Things like infinite loops would leave sublime hanging. Or if id wanna take input from keyoboard, it wouldn't work either. This bash script does exact same thing as far as compiling goes. But when it comes to running program it opens it in new terminal window.
Use this bash script if you want it to automatically run in os x terminal #!/bin/bash# compiles all java files within directory and runs first in new terminal window.for file in.javadoecho 'Compiling $file'javac $filedoneecho 'Running $1.class'echo -e 'cd `dirname $0`nclearnjava $1necho nread -p 042Program Terminated. Press ENTER to continue.042nrm -f sayhi.command' sayhi.command; chmod +x sayhi.command; open sayhi.command. Updated, use this one: #!/bin/bash# compiles all java files within directory and runs the one being edited in new terminal window.for file in.javadoecho 'Compiling $file'donejavac.javaRETVAL=$? $RETVAL -ne 0 && exit $RETVAL -eq 0 && (echo 'Compile Success!:)';echo 'Running $1.class';#Create temporary file (in current directory) to execute compiled java class.#Deletes itself after execution.echo -e 'cd `dirname $0`nclearnjava $1necho nread -p 042Program Executed. Press ENTER to continue.042nrm -f sayhi.command' sayhi.command;chmod +x sayhi.command; open sayhi.command;).
![](/uploads/1/2/6/6/126629689/793583872.jpg)