Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > newbie java ? need help

newbie java ? need help
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2001
Location: boston
Status: Offline
Reply With Quote
Jun 7, 2001, 10:05 PM
 
o.k. I just got mac os x and the developers tools and now i would like to start to develop some java programs.
what are all the difference in java (ex. java, java2, jdk 1.3.1, awt, swing) I went to the book store to pick up a book and didnt know where to start. I was thinking of picking oreilly learning java but i thought i would wait and get some feedback, what would be a good book for a complete novice ( i did take a visual basic course last year so i do understand some programing) I would like to be able to develop on os x but be able to run it on os 9, windows, and unix/linux. is it possible to write it once and run it anywhere or is it more to it than that.
I thought cocoa was object c but i heard people talking about developing java in cocoa is this correct? explain.
are java programs always GUI based or can you write it for use in a CLI.
Sorry about all the crazy questions just didnt know there was so much to java and I havent even tried to write a line of code yet.
     
Dedicated MacNNer
Join Date: Apr 2001
Location: San Francisco, USA
Status: Offline
Reply With Quote
Jun 7, 2001, 11:29 PM
 
Cocoa is available to Java programs, but this breaks the "write once run anywhere" rule. Cocoa is currently only available on the Mac OS X platform. For your code to be truly portable, you can't use OS-specific libraries like Cocoa.

Java's standard tools are all command-line applications: java, javac, javadoc, etc. I suggest learning these. You can pretty much follow the Solaris or Linux tutorials on http://java.sun.com/ in order to get started. There are graphical environments like Project Builder and JBuilder, but you'll find that most online Java documentation refers to the command-line tools.

As far as books are concerned, my favorite is Java in a Nutshell from O'Reilly. However it is aimed at experienced programmers, so definitely look over it to make sure you're at the same level.

Your First Cup of Java (for UNIX)
This looks like a good first step. You can skip the installation steps (just make sure you've installed the Developer CD). The tutorial uses pico and the standard java command-line tools, all of which are found in Mac OS X.

Have fun!
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jun 8, 2001, 12:08 AM
 
Here's the best book on learning Java that I have seen so far.

"Java" by Friedman-Hill, it is part of the "Visual" series.

Each page is essentially composed of actual screen shots along with commentary; minimal reading and a lot more time being hands on. Enough said, those guys have not paid me a cent in endorsement fees -I should begin charging them

[ 06-08-2001: Message edited by: DaGuy ]
iMac 17" G4 800MHZ & 768 SDRAM
     
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Jun 8, 2001, 04:03 AM
 
The definitive answer:

Java as a language is not tied to any GUI, so you can happily write command line tools in it. GUI libraries just add a pile of classes you can use, so learn on a command line first and add graphics later.

AWT (Abstract Windows Toolkit) is the GUI it originally shipped with, but it was painfully simple and primitive. Swing is an extended version of that, that is a lot more sophisticated but also extremely slow. Both are totally cross-platform.

Cocoa is a set of libraries, including GUI libraries, that are specific to OS X. They came from Objective-C but Java can happily use them. They will not work on Windows or Unix.

Any book by O'Reilly is guarunteed to be good, provided it's appropriate. Java in a Nutshell is a very good book once you already know some java - or at least, some other C-derived language - but you need to learn it with something else first. I learnt with a book called Java Gently, but online guides are probably good enough.
All words are lies. Including these ones.
     
Dedicated MacNNer
Join Date: Oct 2000
Location: Pasadena, CA, USA
Status: Offline
Reply With Quote
Jun 8, 2001, 11:26 AM
 
java - the language
java2 - A marketing name for the current version of java
jdk 1.3.1 - The Java Development Kit, version 1.3.1. This is the version included with Mac OS X. It is the most recent production release; although Sun just released the beta of 1.4 for other platforms)
awt - the older suite of classes used in Java for building GUI applications
swing - the current suite of classes used in Java for building GUI applications

Java programs can be written so that they run anywhere. There are some "gotchas", but they're easily dealt with and as you are learning you shouldn't worry about it.

As Sadie said, Cocoa is a set of libraries available to Java applications running on OS X. Use cocoa in your Java application and it won't run under Windows or OS 9, guaranteed.

Java programs can also be written to run only from the command line, although they won't run optimally under OS 9, which doesn't really have a command line.

Erik
     
phobic  (op)
Fresh-Faced Recruit
Join Date: Jun 2001
Location: boston
Status: Offline
Reply With Quote
Jun 23, 2001, 02:12 PM
 
Thanks everyone for the input. Just a few more questions.
ok so I deceided to learn java and I want to focus on just command line stuff for right now and worry about learning gui later. will I be able to add the GUI to my CLI apps or do you have to pretty much rewrite them?
Question two since I am learning the command line first how will it run on a machine running mac os 9 or win98 (i'm quessing though dos ?)?
Here is a list of apps I would like to write. ( instant messager, file sharing, email, mp3 streamer, ftp server and client.) Would it be possible to write these kinda of apps in java ( first in a CLI and then add GUI) or do you think java is the wrong language and I should use something else? I know there are probly apps already available that will do the same thing I just would like to write my on own so I can understand how they work and for personal satisfaction.
Thanks again,
     
Dedicated MacNNer
Join Date: Oct 2000
Location: Pasadena, CA, USA
Status: Offline
Reply With Quote
Jun 23, 2001, 11:52 PM
 
> will I be able to add the GUI to my CLI apps or do you have to pretty much rewrite them?

There's nothing inherent in Java that will prevent writing an app to run on the command line first and then move it over to a GUI. The design pattern being promoted by Sun (Model-View-Controller) makes this process somewhat easier - you write your classes that do the real work without any interface at all, and then layer the interface on top of them.

> Question two since I am learning the command line first how will it run on a machine
> running mac os 9 or win98 (i'm quessing though dos ?)?

On a Windows machine (any version), you will open a dos prompt. On Win 95/98/Me, there may be memory issues; on NT/2000/XP there won't be. On an Mac OS 9 machine, standard out and standard in are generally not displayed, but can be in windows (1 for each). It works, but it isn't ideal.

All of the apps you suggest are possible - I know because most of them have already been written. Do some searches on Yahoo and you'll find example of everything, some of them with sample code.

Erik
     
Fresh-Faced Recruit
Join Date: Apr 2001
Location: Dahoam
Status: Offline
Reply With Quote
Jun 24, 2001, 05:28 AM
 
"chrushFTP" is a nice example of a FTP server written completely in java.
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jun 24, 2001, 10:07 AM
 
You will be able to write all the apps you described in Java. The langauage has very good networking and threading libraries.

Also, there is a lot of useful stuff on the internet; for example: If you go on a Sherlock and search something like "mp3 java" it may dig up some publically available source code for an mp3 player. If the license allows it, you could cut and paste some of the pieces you need -although understanding some of the stuff that's out there can be quite a challenge and a project all on its own.

Finally, code away in the command line. As you do, just keep in mind that at some point you will want to implement Model-View-Controller so organize your code in a way that allows for a straighforward separation once you have a reasonable ammount of core functionality working. Good Luck!



[ 06-24-2001: Message edited by: DaGuy ]
iMac 17" G4 800MHZ & 768 SDRAM
     
Mac Elite
Join Date: Mar 2001
Status: Offline
Reply With Quote
Jun 24, 2001, 06:34 PM
 
Everyone forgot:

Thinking in Java, 2nd edition, Revision 12
©2000 by Bruce Eckel

Which is available on my site at
raman-sinha.com/bruce-eckel/index.html

It's a good, free, read.
     
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Jun 24, 2001, 07:40 PM
 
I learned from a book called "Java, From the Beginning".
     
Junior Member
Join Date: Feb 2000
Location: Chicago, IL
Status: Offline
Reply With Quote
Jun 25, 2001, 02:02 AM
 
Another one I like and often find myself checking when I forget simple things is "How to Program Java" by Peter Coffee. It is not comprehensive, but I found it a great beginner book.

In addition, I like to refer to the "Java Class Libraries" (there are two volumes and a "Supplement for Java2") by Chan, Lee, & Kramer. These are really THE reference books. They are huge and expensive, but tell you how things work literally like a dictionary, whereas most books give you many chunks of things that you kinda have to peice together like a puzzle and try to extrapolate how things work in a different situation.

The "Second Edition, Volume 1" covering java.io.*, java.lang.*, java.math.*, java.net.*, java.text.*, and java.util.* will probabaly cover all you need to know for getting started and doing command line stuff.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:48 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2