Well this Tuesday I will give you a half-mac-tip-half-anything-tip. Java. If you aren’t a programmer, this really won’t apply to you. However, if you are, and would love to be able to write one program and have it run on any system, (including Mac OSX). Even if you don’t own a Mac, you can write a Mac program with it.

Write once. Run anywhere. That’s the slogan for Java and the reason that it has become one of the most popular computer languages ever. Mac OS X integrates Java right into the core of the operating system bringing Java on the Mac to a whole new level. All of the tools required to write, compile and run Java are included and preinstalled with the operating system. You can start using Java right out of the box with Mac OS X. Here’s how:

The steps below explain how to write a simple Hello World program using nothing more than TextEdit and the Terminal program. Java is already built in to the system so there is nothing extra to buy.

TerminalJava CupTextEdit

Launch the TextEdit application that comes with Mac OS X. (You can do this by selecting Go -> Applications in the Finder and then double-clicking on TextEdit.) Create a new document that looks like this:

helloWorldJava

Select Format -> Make Plain Text
Select File -> Save As…

Give the file the name HelloWorld.java and click the Save button. Remember where you save it because you’ll need to know the location later. Your documents folder would probably be a good place.

The system will give you a message that says that the document named HellowWorld.java already seems to have an extension and will ask you if it should append .txt anyway. Click the Don’t append button.
Launch the Terminal program. (You can do this by selecting Go -> Applications in the Finder, then double-clicking the Utilities folder and then double-clicking the Terminal icon.
Change to the directory that contains the HelloWorld.java file that you just saved by typing: cd PATHOFFILE
For example, if the file was located in your Documents folder you would type: cd Documents
Compile the program by typing: javac HelloWorld.java

Run your compiled program by typing: java HelloWorld
You should now see “Hello world!”

Note: The program that you just wrote is faily simple, but it shows
how easy it is to use Java on the Mac. Java is a rich language with and
can be used to write applets for web browsers, servlet for web servers,
full stand-alone cross platform applications or full stand-alone Mac OS
X native applications. It can do graphics, database interaction,
networking and a lot more. Check out some of the resources below to
learn more about Java. If you start doing a lot with it you may want to
start using an Integrated Development Environment (IDE).

For more information on Java, check out the following books:

Teach Yourself Java in 21 Days

Java in a Nutshell


Thinking in Java

Mac Specific Java Web Sites and Resources

Apple’s Java Development Center

Pepsan and Associates Mac Java Page

Developing Java Applications on Mac OS X (pdf)


Developing Cocoa Java Applications (pdf)


Macintosh java-dev Email List


Mac Java Group at Yahoo!

General Java Web Sites


Sun’s Main Java Page


Java Programming Resources
(not pretty, but tons of stuff)

About.com Focus On Java

Well I hope you enojoyed that one. When I started programming, I was using Java. It can be a gateway language into bigger and better things. Well as always if you’ve got anything you need/want/hate you can email me or go post it in the forums, peace out-

-b

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Reddit
  • Furl
  • NewsVine
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • De.lirio.us
  • Fark
  • feedmelinks
  • LinkaGoGo
  • Ma.gnolia
  • Netvouz
  • RawSugar
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

3 Comments to “Using Java For Easy Program Development in OSX”  

  1. 1 Moira Finley

    Thank you a million times over. I have looked everywhere to find out how to use textedit to write programs in java. No book , no Apple website, no Sun website- nowhere does one tell you the simple process of getting java to work on Mac OS X. I cannot tell you how much I appreciate your article.
    Moira Finley

  2. 2 roulette secrets

    Some really interesting info, well written and broadly speaking user genial.

  3. 3 Francisco Aniol

    Your method of describing everything in this article is actually nice, all be capable of easily know it, Thanks a lot.

Leave a Reply