Chapter 14: Ten Sets of Web Resources for

April 6th, 2009

Chapter 14: Ten Sets of Web Resources for Java 327 Although it s not quite as high-profile, sourceforge.netis the place to look for open source software of any kind. The SourceForge repository contains over 80,000 projects. At the SourceForge site, you can download software, read about works in process, contribute to existing projects, and even start a project of your own. SourceForge is a great site for programmers and developers at all levels of experience.

For high quality jboss hosting services please check jboss web hosting website.

326 Part V: The Part of Tens

April 5th, 2009

326 Part V: The Part of Tens Simon Phipps s blog www.webmink.net/minkblog.htm Simon is Chief Technology Evangelist at Sun Microsystems. No matter what subject he chooses, Simon always speaks his mind. Jonathan Schwartz s blog blogs.sun.com/jonathan Jonathan is Chief Operating Officer at Sun Microsystems. When Jonathan speaks, people listen. And when Jonathan writes, people read. Mary Smaragdis s blog blogs.sun.com/mary Mary is Marketing Manager at Sun Microsystems. When you read Mary s blog, her enthusiasm gushes from the computer screen. And I ve met her at several conferences. She s even livelier in person. Looking for Java Jobs Are you looking for work? Would you like to have an exciting, lucrative career as a Java programmer? Then try visiting a Web site that s specially designed for people like you. Point your Web browser to www.javajobs.comor java.computerwork.com. Becoming Certified in Java These days, everybody is anxious to become certified. If you re one of these people, you can find plenty of resources about Java certification on the Web. Just start by visiting www.javaprepare.comand www.javaranch.com/ring.jsp. Both of these sites link to other interesting sites, including sites with practice certification exams. Everyone s Favorite Sites It s true these two sites aren t devoted exclusively to Java. However, no geek-worthy list of resources would be complete without Slashdot and SourceForge. Slashdot s slogan, News for nerds, stuff that matters, says it all. At slashdot. orgyou find news, reviews, and commentary on almost anything related to computing. There s even a new word to describe a Web site that s reviewed or discussed on the Slashdot site. When a site becomes overwhelmed with hits from Slashdot referrals, one says that the site has been slashdotted.

For high quality jboss hosting services please check jboss web hosting website.

Chapter 14: Ten Sets of Web Resources for

April 5th, 2009

Chapter 14: Ten Sets of Web Resources for Java 325 comp.lang.java.programmer comp.lang.java.help comp.lang.java.gui Checking the FAQs for Useful Info Has the acronym FAQ made it to the Oxford English Dictionary yet? Everybody seems to be using FAQ as an ordinary English word. In case you don t already know, FAQ stands for frequently asked questions. In reality, an FAQ should be called ATQTWTOSPOTN. This acronym stands for Answers to Questions That We re Tired of Seeing Posted on This Newsgroup. You can find several FAQs at the official Sun Web site. You can also check www.www-net.com/java/faq a page that links to several Java FAQs. Reading Documentation with Additional Commentary When programmers write documentation, they ask themselves questions and then answer those questions as best they can. But sometimes, they don t ask themselves all the important questions. And often, they assume that the reader already knows certain things. If you re a reader who doesn t already know these things, you may be plain out of luck. One way or another, all documentation omits some details. That s why other peoples comments about the documentation can be so helpful. At www. jdocs.comexperienced Java programmers annotate existing Java documentation with their own comments. The comments include tips and tricks, but they also add useful pieces of information pieces that the documentation s original authors omitted. If you need help with an aspect of the Java API, this is a great Web site to visit. Opinions and Advocacy Blogs are hot stuff these days. Business people, politicians, and others write blogs to draw attention to their ideas. And many people write blogs just for fun. When it comes to reading about Java, I have a few favorite blogs. I list them here in alphabetical order:

For high quality website hosting services please check cheap web hosting website.

324 Part V: The Part of Tens Finding

April 5th, 2009

324 Part V: The Part of Tens Finding News, Reviews, and Sample Code The Web has plenty of sites devoted exclusively to Java. Many of these sites feature reviews, links to other sites, and best of all, oodles of sample Java code. Some also offer free mailing lists that keep you informed of the latest Java developments. Here s a brief list of such sites: Java Boutique: javaboutique.internet.com JavaRanch: www.javaranch.com Javalobby: www.javalobby.org Gamelan: www.developer.com/java Improving Your Code with Tutorials To find out more about Java, you can visit Sun s online training pages. The Web address is java.sun.com/developer/onlineTraining. Some other nice tutorials are available at the following Web sites: Richard Baldwin s Web site: www.dickbaldwin.com IBM developerWorks: www-106.ibm.com/developerworks/ training ProgrammingTutorials.com: www.programmingtutorials.com Finding Help on Newsgroups Have a roadblock that you just can t get past? Try posting your question on an Internet newsgroup. Almost always, some friendly expert posts just the right reply. With or without Java, you should definitely start exploring newsgroups. You can find thousands of newsgroups groups on just about every conceivable topic. (Yes, there are more newsgroups than For Dummies titles!) To get started with newsgroups, visit groups.google.com. For postings specific to Java, look for the groups whose names begin with comp.lang.java. For a novice, the following three groups are probably the most useful:

For high quality jboss hosting services please check jboss web hosting website.

Chapter 14 Ten Sets of Web Resources for

April 4th, 2009

Chapter 14 Ten Sets of Web Resources for Java In This Chapter Finding resources from Sun Microsystems Getting sample code Reading the latest Java news Starting out help for Java beginners Moving up jobs, certification, and more for experienced programmers No wonder the Web is so popular. It s both useful and fun. This chapter has ten bundles of resources. Each bundle has Web sites for you to visit. Each Web site has resources to help you use Java more effectively. And as far as I know, none of these sites uses adware, pop-ups, or other grotesque things. The Horse s Mouth Sun s official Web site for Java is java.sun.com. This site has all the latest development kits, and many of them are free. In addition, Sun has two special- purpose Java Web sites. Consumers of Java technology should visit www.java.com. Programmers and developers interested in sharing Java technology can go to www.java.net. And be sure to visit www.jcp.org, home of the Java Community Process. At this site, you can read the latest proposals for improving Java. Who knows? You may even want to contribute.

If you looking for unlimited one inclusive web hosting plan please check web hosting plan website.

322 Part V: The Part of Tens

April 4th, 2009

322 Part V: The Part of Tens

For high quality java hosting services please check java web hosting website.

Chapter 13: Ten Ways to Avoid Mistakes 321

April 4th, 2009

Chapter 13: Ten Ways to Avoid Mistakes 321 out.println(fileName); } } } This program displays a list of all the files in the windowsdirectory. (For clarification on the use of the double backslash in \windows , see Chapter 8.) But what happens if you change \windowsto something else something that doesn t represent the name of a directory? File myFile = new File( &*%$!! ); Then the new Filecall returns null(a special Java word meaning nothing), so the variable myFilehas nothing in it. Later in the code, the variable dir refers to nothing, and the attempt to loop through all the dirvalues fails miserably. You get a big NullPointerException, and the program comes crashing down around you. To avoid this kind of calamity, check Java s API documentation. If you re calling a method that can return null, add exception-handling code to your program. For the story on handling exceptions, see Chapter 12. For some advice on reading the API documentation, see Chapter 3 and this blog s Web site. Helping Java Find Its Files You re compiling Java code, minding your own business, when the computer gives you a NoClassDefFoundError. All kinds of things can be going wrong, but chances are that the computer can t find a particular Java file. To fix this, you must align all the planets correctly. Your project directory has to contain all the Java files whose names are used in your code. If you use named packages, your project directory has to have appropriately named subdirectories. Your CLASSPATH must be set properly. For specific guidelines, see Chapter 15 (on the CD-ROM) and this blog s Web site.

If you looking for unlimited one inclusive web hosting plan please check web hosting plan website.

320 Part V: The Part of Tens class

April 4th, 2009

320 Part V: The Part of Tens class WillNotWork { String greeting = Hello ; public static void main(String args[]) { System.out.println(greeting); } } You get an error message because mainis static, but greetingisn t static. For the complete guide to finding and fixing this problem, see Chapter 10. Staying within Bounds in an Array When you declare an array with ten components, the components have indices 0 through 9. In other words, if you declare int guests[] = new int[10]; then you can refer to the guestsarray s components by writing guests[0], guests[1], and so on, all the way up to guests[9]. You can t write guests[10], because the guestsarray has no component with index 10. For the latest gossip on arrays, see Chapter 11. Anticipating Null Pointers this blog s examples aren t prone to throwing the NullPointerException, but in real-life Java programming, you see that exception all the time. A NullPointerExceptioncomes about when you call a method that s supposed to return an object, but instead the method returns nothing. Here s a cheap example: import static java.lang.System.out; import java.io.File; class ListMyFiles { public static void main(String args[]) { File myFile = new File( \windows ); String dir[] = myFile.list(); for (String fileName : dir) {

For high quality java hosting services please check tomcat web hosting website.

Chapter 13: Ten Ways to Avoid Mistakes 319

April 3rd, 2009

Chapter 13: Ten Ways to Avoid Mistakes 319 public SimpleFrame() { JButton button = new JButton( Thank you… ); setTitle( …Katie Feltman and Heidi Unger ); setLayout(new FlowLayout()); add(button); button.addActionListener(this); setSize(300, 100); setVisible(true); } Whatever you do, don t forget the call to the addmethod. Without this call, you go to all the work of creating a button, but the button doesn t show up on your frame. For an introduction to such issues, see Chapter 9. Adding Listeners to Handle Events Look again at the previous section s code to construct a SimpleFrame. If you forget the call to addActionListener, nothing happens when you click the button. Clicking the button harder a second time doesn t help. For the rundown on listeners, see Chapter 16, which is on the CD-ROM. Defining the Required Constructors When you define a constructor with parameters, as in public Temperature(double number) then the computer no longer creates a default parameterless constructor for you. In other words, you can no longer call Temperature roomTemp = new Temperature(); unless you explicitly define your own parameterless Temperatureconstructor. For all the gory details on constructors, see Chapter 9. Fixing Non-Static References If you try to compile the following code, you get an error message:

If you looking for unlimited one inclusive web hosting plan please check web hosting plan website.

318 Part V: The Part of Tens Breaking

April 3rd, 2009

318 Part V: The Part of Tens Breaking Out of a switch Statement If you don t break out of a switchstatement, you get fall-through. For instance, if the value of verseis 3, the following code prints all three lines Last refrain, He s a pain, and Has no brain. switch (verse) { case 3: out.print( Last refrain, ); out.println( last refrain, ); case 2: out.print( He s a pain, ); out.println( he s a pain, ); case 1: out.print( Has no brain, ); out.println( has no brain, ); } For the full story, see Chapter 5. Comparing Values with a Double Equal Sign When you compare two values with one another, you use a double equal sign. The line if (inputNumber == randomNumber) is correct, but the line if (inputNumber = randomNumber) is not correct. For a full report, see Chapter 5. Adding Components to a GUI Here s a constructor for a Java frame:

For high quality java hosting services please check java web hosting website.