aspose file tools*
The moose likes Mac OS and the fly likes Java SDK on a Mac Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "Java SDK on a Mac" Watch "Java SDK on a Mac" New topic
Author

Java SDK on a Mac

Jared Knowlton
Greenhorn

Joined: Sep 20, 2003
Posts: 17
I read in the book Head First Java that a Java 2 SDK compiler is included in Mac OSX. Where do I find it and how do I launch it? Or am I the only one who dares to use Java on a Mac?
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
Java on Mac OS X is great. I use my macs to develope java everyday. You will find your SDK binaries in /Library/Java/Home/bin. Just set your $JAVA_HOME variable to /Library/Java/Home and off you go.
Jared Knowlton
Greenhorn

Joined: Sep 20, 2003
Posts: 17
I went to the library and java was not in the list. I then did a search for java and this is what it came up with:
com.apple.java.util.prefs.plist
DMJava (Folder)
DMJavawebstart (Folder)
Java Applets (Folder)
Java Web Start (Folder)
java.plist
javaws.cfg
Do I need to install it somehow?
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
That is rather strange. What version of OX X are you using 10.0? 10.1.x? The /Library/Java is actually a sys link the actual location of the Java Home path. I am not at my mac right now so I can't tell you the exact location but I will later. Just let me know what version of OS X you are using and we can figure this out.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Or am I the only one who dares to use Java on a Mac?

Hardly, some other notable Java/Macheads are James Gosling (Java) and James Duncan Davidson (Tomcat). And of course, me! (OK, not so famous).
By the way, there's a Mac/Java forum on this site here.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

And I'm not completely sure, but it may be that the Java run-time is included in the base system, but you may need to install the (free) Dev Tools to get the JDK???
I'm not sure if this is the case since I routinely install the Dev Tools along with the base OS so I'm not sure where the distinction lies. Something to check out though...
hth,
bear
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
I'm going to move this to the Mac OS forum. Please post any followups there.
[ September 24, 2003: Message edited by: Jason Menard ]
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Try just opening a terminal window and typing java or javac - what happens? I don't remember having to set anything up and, AFAIK, Java is preinstalled.
Jared Knowlton
Greenhorn

Joined: Sep 20, 2003
Posts: 17
I'm on Mac OSX 10.2.6. I did try javac from the terminal window and it seems to work but I didn't have anything to compile. I'll write a program and I'll try compiling it.
Jared Knowlton
Greenhorn

Joined: Sep 20, 2003
Posts: 17
I can compile a program but I can't get it to run.
There error it comes up with is as follows:
Exception in thread "main" java.lang.NoClassDefFoundError: mortgage (wrong name: Mortgage)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Sounds like you have a casing problem. Be sure to specify the class name as Mortgage everywhere. "mortgage" will not do.
bear
Jared Knowlton
Greenhorn

Joined: Sep 20, 2003
Posts: 17
Originally posted by Bear Bibeault:
Sounds like you have a casing problem. Be sure to specify the class name as Mortgage everywhere. "mortgage" will not do.
bear

I'm not quite sure what you mean by that, are you saying that I need to change the class name to Mortgage everywhere.java ?
javac mortgage.java
java mortgage everywhere
Please give me an example of how I run and compile
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
I think what Bear meant by casing problem is simply writing the first letter of the class name with an uppercase or lowercase letter: Mortgage as opposed to mortgage. The two spellings are not interchangeable.
Most class names start with an uppercase letter, kind of a style convention. So for your class you'd usually use Mortgage to name it. In your .java file you'd write
public static void main Mortgage{
// class stuff

}
and you'd save the file as Mortgage.java
To compile it and then run it:
javac Mortgage.java
java Mortgage

maybe this helps?
Pauline
[ September 25, 2003: Message edited by: Pauline McNamara ]
Jared Knowlton
Greenhorn

Joined: Sep 20, 2003
Posts: 17
Yes Pauline that worked - I was able to run the program. I can't believe I overlooked something as simple as that. Thanks for your help all.
 
wood burning stoves
 
subject: Java SDK on a Mac