TextWrangler is a great free lite version of the long established BBEdit editor. I can't really see whats so light about it.
Anyway, you can download TextWrangler at Bare Bones Software.
But to make it easier to compile and run java from a menu within TextWrangler, I recommend adding two new commands by downloading two files that are applescript and moving them into the scripts folder for TextWrangler. I thank nonoTux.com for these original scripts.
To install the scripts, open TextWrangler, in the script menu(the 2nd one to the left of the help menu), open the script editor and use it to create a new file, and paste the following:
tell application "TextWrangler"
save text document 1
set the_file to file of text document 1
end tell
set AppleScript's text item delimiters to ":"
set source_file to the last text item of (the_file as string)
tell application "Finder"
set the_folder to container of the_file as alias
end tell
tell application "Terminal"
activate
set shell_script to "cd " & (quoted form of POSIX path of the_folder) & ¬
"; javac " & source_file
if (count windows) is 0 then
do script shell_script
else
do script shell_script in the front window
end if
end tell
and then save the file with the name Compile java.scpt into theLibrary/Application Support/TextWrangler/Scripts directory, look for Library in you home users folder.
Then create another new script file and paste this code:
tell application "TextWrangler"
set the_file to file of text document 1
end tell
set AppleScript's text item delimiters to ":"
set source_file to the last text item of (the_file as string)
set compiled_file to text 1 thru -6 of source_file
tell application "Finder"
set the_folder to container of the_file as alias
end tell
tell application "Terminal"
activate
set shell_script to "cd " & (quoted form of POSIX path of the_folder) & ¬
"; java " & compiled_file
if (count windows) is 0 then
do script shell_script
else
do script shell_script in the front window
end if
end tell
and then save the file with the name Run java.scpt into the
Library/Application Support/TextWrangler/Scripts directory, look for Library in you home users folder.
You will now have two new menu items in the scripts menu (the 2nd one to the left of the help menu). They will open a terminal window and compile or run your front window as a java program.

Hi Professor Jenkins,
ReplyDeleteI'm actually the author of the top script. I posted it on dzone back in 2006.
http://snippets.dzone.com/user/georgesb
I've been using TextWrangler to teach AP Computer Science for quite a while. It's exciting to see my work used by a college professor. I'm a Computer Science teacher in LA Unified. (Hollywood High)
Regards,
George Benainous
Hey there Benainous! Its me Norberto Sanchez!
ReplyDeleteNow in college im starting my programming classes and since I got my hands on a mac I remembered we used to use TextWrangler for coding. Now I'll be doing the same, as well as using your script! Thanks!
Awesome! Thank you so much! I'm taking my first Java class. This is great.
ReplyDelete