This may infact test that theory, but here we go. I work as a PM in the software biz, but unlike most having taken another path was never a developer... so to better understand the trials and tribulations of my co-workers I have begun a campaign of self eduaction, starting with JAVA.
I got a book - Head First Java - and have a computer - an iBook - but my confusion comes from being a JAVA novice (neophyte?) as well as this being my first MAC. It would appear that when I write my code I do it a text file. Then what?
I am too proud to do the easy thing and ask one of our developers, so please take pitty on me.....
Happy New Year!
[ EJFH: Edited subject to reflect content of post ] [ January 05, 2005: Message edited by: Ernest Friedman-Hill ]
Indeed, no question is too simple or too small. I don't think your question is really all that small or simple, though! Let me rephrase it for you:
"How do I get started in Java development on the Mac?"
Given that wording, you'd agree, I'm sure, that our MacOS forum is actually a better place for your question. I'm going to move this thread there, therefore, where it will get the attention of the appropriate people. While you're waiting, you might also want to browse some older threads in that forum to get ideas.
There's not a whole lot special about Java on a Mac once you have everything set up. So almost all of the info in the other Java forums will be applicable. Especially info on the language itself and how to write good programs.
Out of the box, OS X will have a JRE. In order to get the Java compiler I believe you may need to download and install the Developer Tools from the Apple site. Even if that's not necessary to get the complier (I'm not 100% sure since I always install them), you should do this to obtain great tools like Ant and CVS.
Bring a up an instance of the Terminal application (which gives you a Unix shell prompt) and off you go.
You can write your programs in a simple text editor (make sure you don't create formatted text), or use on of the many IDEs that run on OS X.
Just to add to what's already been said... You do get the java compiler out of the box with Mac OSX, no need to install any extra tools right away.
You can find the Terminal application in the Utilities folder of the Applications folder.
The link above to Sun's Java tutorial on the mac is oooold - it shows screenshots of OS 9, ouch! I wouldn't go there, that's history (thank goodness).
After a quick look around I couldn't find a simple HelloWorld tutorial for OS X, but there must be one out there.
Maybe I can fill in the obvious stuff for you. (I apologize in advance if it's insultingly obvious.) You've written your code to a text file, like HelloWorld.java - then what? To compile it, you open up the Terminal like Bear said.
When you open up the Terminal you're in a certain location in your file system. It looks like this:
(That's the prompt. It's waiting for you to type in a command so it can do something for you, like compile your java program.)
That location is the same as your "home", the little house icon with your user name next to it in a Finder window. Let's assume, though, that you've saved your HelloWorld.java file in Documents/MyJavaStuff.
On to compiling your source file. The compiler needs to know where your .java file is. (There are a few ways of getting the compiler to look in the right place, what follows is just one way.) It will look in the current location in the Terminal (your "home") for HelloWorld.java. But it's not there, so you need to change your location in the Terminal to the directory Documents/MyJavaStuff. You do that with a cd command, that stands for "change directory". Like this:
You're now located in the same directory as your HelloWorld.java file, so the compiler should be able to find it OK.
To use the java compiler, after the $ prompt you type in
If all went well, you should now have a HelloWorld.class file in your MyJavaStuff folder.
To run the freshly compiled program, now you type in
If you've written HelloWorld the usual way, you should see Hello world! appear on the next line. That's it. Unless some errors popped up in the compiling or running process. If so, c'mon back with those...
I would like to ask which IDE your developer's use at work?
The book you have chosen (Head First Java) is a great book to start with. It not only tells you the basics of Java but also allows you to get a handle on OO development. I would recommend the following for getting started:
Learn about the use of packages. Why are they good to use and how you can set them up.
Take a look at Ant. If you are interested in diving deeper and deeper in to the world of Java, taking the time to learn the basics of Ant will save you a lot of time in the future.
Hello World! is the standard starting point but do some multi-class examples early on. You need to gain an understanding of how classes use and interact with one another. Also, in order to understand OO, you will need to understand why some things need to be in separate classes and why others need to be together.
*******This should probably be at the top of the list. Learn how to use the API and USE IT!!! It is one of the best features of Java and the greatest asset a programmer can have.