• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java on MAC OS 10.4

 
Jeffrey Price
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Total beginner. How do I enter code, compile, and execute JAVA on OS 10.4?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15448
42
Android IntelliJ IDE Java Scala Spring
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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$
 
william gates
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65123
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See Tomcat on Mac OS for help.
 
Andreanes Yosef Vanderlee
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
stephen gates
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65123
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by stephen gates:
So using something like eclipse is out of the question?


Said who?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Andreanes Yosef Vanderlee
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Thomas Hezel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thomas Hezel:
...Thank you for helping a beginner...

I'm glad it helped!

Welcome to JavaRanch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic