Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Rather Sad Problem

 
Bryan Wulzen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After deciding to learn java, and purchasing a book to do so, I'm having some difficulties starting out. I'm on a Mac, version 10.4.11, and according to every source I've looked at, the JDK should be packaged into my computer somewhere. I've spent a solid half hour diving through files to try and find this elusive program, and have used spotlight for every combination of 'java development kit' possible with no luck.

So, could someone help me out? Where is the JDK found? Be as condescending as you like!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64844
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bring up a Terminal window and type the "java -version" command. What happens?

If it prints something like:then Java is installed and you are all set.

If not, and you get a "command not found" error, it's not.

I've been on Leopard (10.5) for some time now, so I don't recall if Tiger needs the Developers Tools to be installed in order to get Java.
 
Bryan Wulzen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yay, my first step in the right direction! I get nearly the same message as you, with slightly different numbers (naturally). However, I'm not entirely clear here -- where exactly do I type in code? Thanks for your help and patience with me.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

You use the same terminal window to execute Java code.

Navigate somewhere with the commands (probably "cd" and name of directory).
Use the commands to create a folder/directory for your Java Work. Maybe you'll call it Java, or JavaWork, or similar. Maybe "mkdir Java".
Use "cd" to go into that directory.
Use a text editor to save a .java file in that directory. If it's a HelloWorld program, then you would save the file "HelloWorld.java"
Compile it to bytecode with the command "javac HelloWorld.java"
Look at the long list of errors, and see if you can understand any of them.
When you stop getting any errors, get the java application to interpret the bytecode with the command "java HelloWorld".
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, if you go to the Java Tutorials you find a letter-by-letter guide to a HelloWorld application, and it has a list of common errors. If you try "javac Foo.java" and nothing happens, assume the compilation has be successful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic