This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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!
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.
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".
Joined: Oct 13, 2005
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.