aspose file tools*
The moose likes Mac OS and the fly likes JAVA on MAC OS 10.4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "JAVA on MAC OS 10.4" Watch "JAVA on MAC OS 10.4" New topic
Author

JAVA on MAC OS 10.4

Jeffrey Price
Greenhorn

Joined: Mar 13, 2007
Posts: 2
Total beginner. How do I enter code, compile, and execute JAVA on OS 10.4?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14342
    
  22

http://developer.apple.com/java/


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

It's strange, but I couldn't find a "Hello World" example for Mac that doesn't use some sort of IDE like Xcode. So here are the basic steps using a text editor and the command prompt.

The good news is that Java should be ready to go on the Mac, so you shouldn't have to download, install, or configure anything.

You can write Java code using TextEdit (Finder > Applications > TextEdit.app). When you launch TextEdit, the default is probably for Rich Text. Under the TextEdit's Format menu, select "Make Plain Text." Type the following code letter for letter (Java is case sensitive) in TextEdit...

From TextEdit's File menu, select Save As, and select a folder to save in. For the file name, type "HelloWorld.java" (without the quotes). When you save, TextEdit will ask if you want to use the .java extension instead of .txt. Use the .java extension.

Next open Terminal (Finder > Applications > Utilities > Terminal.app). At the prompt, use the command cd (change directory) to go to the folder where you saved HelloWorld.java. For example...

computerName:~ userName$ cd java/tests
computerName:~/java/tests userName$

Next, compile your .java file by typing javac followed by a space and the file name (including the .java extension).

computerName:~/java/tests userName$ javac HelloWorld.java
computerName:~/java/tests userName$

If the prompt returns without error, then the file has compiled. You will have a new HelloWorld.class file in the folder along with your original .java file. To run the .class file, type java followed by a space and the class name (without the .class extension). Your output should display on the following line.

computerName:~/java/tests userName$ java HelloWorld
Hello World from a Mac!
computerName:~/java/tests userName$


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
william gates
Ranch Hand

Joined: Feb 21, 2007
Posts: 112
What about jsps, ejbs, j2ee stuff on the i-mac.

I purchased one last night and searched breifly and found various forums but didn't have the time to search that long. I did know that when i went to download the j2ee sdk, there were no listings for MAC or OS10.4.

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61628
    
  67

Tomcat runs fine. Just download and untar. Resin, the same.

I believe JBoss as well, but have no personal experience.

Ant and so on all just work fine.

Ain't unix wonderful?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

See Tomcat on Mac OS for help.
Andreanes Yosef Vanderlee
Greenhorn

Joined: Mar 30, 2007
Posts: 12
I used Jdeveloper 10.1.3 and netbeans 5.5 for mac os.. It's a very good IDE, and both of them bundled with the servlet container.. I recommend you to look at those tools.

Regards,
Andre
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

One thing that is suggested by some books is to first do a HelloWorld from the command-line.

1. Use the text-editor of your choice and make sure that you save as plain text.
2. From the command-line run the Java compiler.

javac HelloWorld.java

3. Also from the command-line, run the Java byte-code interpreter.

java HelloWorld.

This first HelloWorld program teaches that java tools aren't necessarily part of the IDE that you're using.

Also of value, is to run the command:

java -version

This will display the default version of Java that you're using -- you may have more than one version installed though.

To do real work, you'll need an IDE such as NetBeans, Eclipse, or XCode -- they're all free. XCode is Apple's IDE.

There are so many templates in XCode that it's hard to find a simple one for a HelloWorld and/or simple exercises, using Java.

According to Apple, the "Java Tool" template is right for HelloWorld and it's good for exercises where you may need a debugger.

NetBeans, Eclipse, and XCode are all professional tools.

I've tried BlueJ, but in my opinion, it does too much hand-holding trying to make things simple and it penalizes you if you know anything. For example, I couldn't type in a package declaration -- BlueJ requires too many things to go through its menus.

Kaydell
[ April 12, 2007: Message edited by: Kaydell Leavitt ]
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Originally posted by william gates:
What about jsps, ejbs, j2ee stuff on the i-mac.

I purchased one last night and searched breifly and found various forums but didn't have the time to search that long. I did know that when i went to download the j2ee sdk, there were no listings for MAC or OS10.4.

thanks


If you want to use EJBs - and the server should be free - there is JBoss and if you want to run the new EJB3 you should try SUN's Glassfish (JBoss can also run EJB3, but then you need to run a beta version or do some extra installation on the production version)


Regards, Rene Larsen
Dropbox Invite
stephen gates
Ranch Hand

Joined: Apr 30, 2007
Posts: 69
So using something like eclipse is out of the question?

Using Tomcat, JBoss, or whatever else is nice but i don't need to use a server, I can test on one, but if I can't compile simple servlets or ejbs i'll just go back to windows or linux.

I write a lot of j2ee apps, jsps, jstl files, servlets and on eclipse 3.2, after downloading a few plugins, I could compile, run, test, and build jar and ear files. Nothing to complex.. Took about 30 minutes to download, set up the plugins, set up my path, set up my build.xml file and then program away.

But I recently bought a Mac with OS 10.4 and while building simple java programs is nice, it does not seem to be that easy to build j2ee apps.

I've used windows and linux over the years and building j2ee apps wasn't that difficult. I haven't been that impressed with my Mac when it comes to building j2ee apps.
[ May 03, 2007: Message edited by: stephen gates ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61628
    
  67

Originally posted by stephen gates:
So using something like eclipse is out of the question?


Said who?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by stephen gates:
Using Tomcat, JBoss, or whatever else is nice but i don't need to use a server, I can test on one, but if I can't compile simple servlets or ejbs i'll just go back to windows or linux.

I write a lot of j2ee apps, jsps, jstl files, servlets and on eclipse 3.2, after downloading a few plugins, I could compile, run, test, and build jar and ear files. Nothing to complex.. Took about 30 minutes to download, set up the plugins, set up my path, set up my build.xml file and then program away.

But I recently bought a Mac with OS 10.4 and while building simple java programs is nice, it does not seem to be that easy to build j2ee apps.

I've used windows and linux over the years and building j2ee apps wasn't that difficult. I haven't been that impressed with my Mac when it comes to building j2ee apps.

I bought a Mac some 6 months ago and have so far stumbled to exactly zero reasons for using something else than my Mac for J2EE development.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Andreanes Yosef Vanderlee
Greenhorn

Joined: Mar 30, 2007
Posts: 12
Originally posted by stephen gates:
So using something like eclipse is out of the question?

Using Tomcat, JBoss, or whatever else is nice but i don't need to use a server, I can test on one, but if I can't compile simple servlets or ejbs i'll just go back to windows or linux.

I write a lot of j2ee apps, jsps, jstl files, servlets and on eclipse 3.2, after downloading a few plugins, I could compile, run, test, and build jar and ear files. Nothing to complex.. Took about 30 minutes to download, set up the plugins, set up my path, set up my build.xml file and then program away.

But I recently bought a Mac with OS 10.4 and while building simple java programs is nice, it does not seem to be that easy to build j2ee apps.

I've used windows and linux over the years and building j2ee apps wasn't that difficult. I haven't been that impressed with my Mac when it comes to building j2ee apps.

[ May 03, 2007: Message edited by: stephen gates ]


If you already use java n develop j2ee application for over the years, you shouldn't find any difficult if you move to other OS. Beside that, linux and mac is very very similar...

I've used mac since hackintosh version, and then I buy the real mac, coz it's really amazing..
Glen Ihrig
Greenhorn

Joined: Mar 12, 2007
Posts: 8
Just in case there is any doubt about Eclipse on Mac OS X...

I Work with Eclipse and commercial tools from Visual Paradigm and Instantiations on OS X.

So far I have been able to do everything with Eclipse on OS X that I can do with Eclipse on Windows.

Eclipse works fine for me under OS X.

As for the JDK on OS X, it's installed with Mac Developer Tools from the OS X install media. The Mac I bought in November 2006 came with JDK 1.4. If you want to up grade to a newer JDK see: http://developer.apple.com/java/

-Glen
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
Originally posted by Bear Bibeault:


Said who?


I use Eclipse 3.2.2 on mac 10.4.9. Eclipse actually seems faster on mac than on Windows.


comp.lang.javascript FAQ: http://jibbering.com/faq/
Thomas Hezel
Greenhorn

Joined: Jul 14, 2007
Posts: 1
Thank you marc weber.
After a long long search I finally got one who helped a real beginner.
Bevore I was lost in a circle.
Its all in the system yes!
Go to sun.
Go to Apple.
Apple its all in the system.
But where ???

Thank you for helping a beginner with your smart and clear "Terminal" adwise!!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Thomas Hezel:
...Thank you for helping a beginner...

I'm glad it helped!

Welcome to JavaRanch!
 
jQuery in Action, 2nd edition
 
subject: JAVA on MAC OS 10.4