Skip to content


5 Tips for Debugging Java Code in Eclipse

5 tips you can use while debugging your Java code in Eclipse.

  1. Logical Structure
    The logical structure is very handy for examining things like maps and other java collections classes, instead of showing the full detail of all the internal variables the view will only show the “logical” pieces. It is activated/deactivated from “Variables” view using logical structure toggle button.


  2. Conditional Debugging
    Once you know where an error occurs, you will want to see what the program is doing right before it crashes. One way to do this is to step through every statement in the program, one at a time, until you reach the point of concern. Sometimes it’s better to just run a section of code and stop execution at that point so you can examine data at that location. It’s possible to declare conditional breakpoints triggered whenever the value of an expression changes. In addition, code assist is available when typing in the conditional expression.

    Right click your breakpoint and select Breakpoint Properties… to set a condition. Check “Enable Condition” box and write your expression below it. You can define a “hit count” that stops your code after that count is reached if you want.

  3. Java Exception Breakpoint
    Use “Java Exception Breakpoint” feature to track your exceptions more easily. For example, your program might be throwing a NullPointerException or FileNotFoundException and you want to track it down. Rather than go to the line of code and set a breakpoint, you can specify that the debugger should always stop when the exception occurs.

  4. Step Filtering
    “Step Into” is one of the most used feature while debugging the source code. Sometimes, it takes us through several stack traces to reach the code we want to debug. In such cases, “Step with Filters” functionality can help us. It simply filters out the classes that we don’t want to step into.

    To specify which classes to filter out when “Step with Filters” is used, the preferences must be set. To activate the preferences panel choose Window > Preferences from the main window. Once there navigate to Java > Debug > Step Filtering and choose the classes/packages to be filtered out. When you step through the code, ensure that the “Use Step Filters” toggle button in Debug view is on.

  5. Expression Evaluation
    “Inspect” is a handy feature for evaluating your expressions. In the Debug perspective, select your expression, right click it and select “Inspect” from the menu to evaluate. You can do it by simply Ctrl+Shift+I key combination.

    “Display View” is another efficient helper in evaluating expressions. Activate it from Window > Show View > Display, write your expressions to evaluate and execute them by right clicking and selecting “Display” from the context menu in the Debug perspective or simply by Ctrl+Shift+D shortcut. You can use code assist (Ctrl+Space) to compose your expressions.

Happy debugging. :D

Posted in Eclipse, Java, Tips & Tricks.

Tagged with , , , , .


25 Popular Social Music Services

I try to list (randomly) popular social music services in this post. It is not the complete list of course. We can add our discoveries to this list. I hope you enjoy it. ;)

  1. Last.fm
    Users can create custom radio stations and playlist from any of the audio tracks in Last.fm’s music library, and are able to listen to some individual tracks on demand, or download tracks if the rights holder has previously authorised it.

  2. Imeem
    Imeem is a social media service where users interact with each other by watching, posting, and sharing content of all digital media types, including blogs, photos, audio, and video.

  3. Pandora
    Pandora is an automated music recommendation and Internet radio service (US only for now).

  4. Finetune
    Type an artist’s name, finetune creates a playlist of related songs for you to listen to. Explore the finetune community – browse artists, users, playlists and more.

  5. Mog
    Listen to millions of full-length songs for free. Share your music library, playlists and opinions on music. Discover music recommended by users who share your musical tastes.

  6. Myspace Music
    MySpace is now one of the biggest social network site on the Internet. So it’s obviously a great place to hunt for music if you are looking for recommendations from friends.

  7. iLike
    Discover new music with your friends. Over 20 million people use iLike to share music tastes and playlists, and to learn about new artists and concerts together.

  8. RadioBlogClub
    Bookmark your favorite tracks and build-up your playlist. Then listen to your juke.blog player.

  9. Jango
    Custom radio that plays the music you want.

  10. iJigg
    Discover, rate and download free music.

  11. Grooveshark
    Free streaming. Social networking. Music discovery.

  12. Live365
    Thousands of free online radio stations.

  13. Musicovery
    Interactive web radio with attractive user interface.

  14. UPlayMe
    Keep up with friends and meet people through the music & videos you’re playing right now.

  15. QLoud
    Qloud provides the music experience users want: unlimited, on-demand, free music from endless library.

  16. Audiofarm
    Audio sharing.

  17. Mystrands Music
    Browse and share popular music.

  18. Musicmesh
    Discover related music and artists.

  19. Jiwa
    Hundreds of thousands of songs to listen to unlimited.

  20. Soundpedia
    Rediscover music you like.

  21. Media Master
    Your music. Anywhere.

  22. Deezer
    Music on-demand.

  23. Sideload
    Free music on the internet to sideload into your locker.

  24. Tun3r
    Your mood. Your station.

  25. Fiql
    Source for music and video playlists.

Happy listening. :D

Posted in Web 2.0.

Tagged with , , , , , .


Great Firefox Extension: Read It Later

Sometimes, I cannot find time to read my daily selected articles. I bookmark them, later I forget to read. E-mailing those articles can be a solution, however it is not effective and takes time to manage.

“Read It Later” is a Firefox extension that creates a manageable list of links to be read later. New features of it for Firefox 3 users are:

  • One click saving, sorting, tagging
  • Sync your list with any number of computers
  • Offline reading
  • Access anywhere
  • RSS feeds
  • Click to save mode
  • Save all tabs for later

Let’s see it in action:

  1. You like a page and want to save it for later reading. Just click the little “tick” at the end of the address bar. It is added your list and the little “tick” turns red. You can add links to your list by right clicking on the link and selecting “Read This Link Later”.

  2. You want to read them now. Click the little “book” icon in the navigation toolbar and select the desired link from the list.

  3. You are complete with the link and want to delete it from the list. Just click the “tick” icon in the address bar one more time, select the “Just Mark As Read” button to delete it. You can add your link to losts of social sites here before deletion if you want.

Tip: You can add links to your list quickly with the “Click to Save Mode” option. You click the links and they are added to your list automatically rather than followed through. It is activated by pressing “Alt + m” or clicking the little red “tick” icon in the bottom right corner. Try it.

Detailed explaination about “Read It Later” is here.
Firefox add-on page for “Read It Later” is here.

I think, it is great. Happy reading. :D

Posted in Firefox.

Tagged with , , , , .


My Top 10 Source Code Search Engines

Here is my top source code seach engines and I wanna share them with you.

  1. Google Code Search

  2. Krugle
  3. Byte My Code
  4. Dzone Snippets
  5. Code Fetch
  6. Codase
  7. Snipplr
  8. O’reilly Code Search
  9. JSourcery
  10. Merobase

Please share yours with us.
Happy coding. :D

Posted in Online Tools, Programming.

Tagged with , , , .


Say “Hello World!” Without Main Method in Java

Can you print out “Hello World!” without writing a main method in Java? Think for a while. Yes, you’re right. It can be possible using “static initialization blocks”. Let’s see the source code first:

package net.cavdar.staticinitializer;

/**
* Says “Hello World!” without main method. A simple use of
* static initialisation.
*
* @author accavdar
*/
public class HelloWorldWithoutMain {
static {
System.out.println(“Hello World!”);
System.exit(0); // prevents “main method not found” error
}
}

So, what is “static initializer block”?

  • A static initializer block is defined using the keyword static.
  • The code in a static initializer block is executed once by the virtual machine when the class is loaded.
  • A static initializer block cannot contain a return statement. Therefore, no need to specify a return type.
  • A static initializer block doesn’t have an argument list.
  • It can initialize only static data members of the class.

Because the static initializer block is executed when the class is first loaded, we can print out “Hello World” without writing a main method. The execution is stopped using “System.exit()” command. So, we prevent “main method not found” error. It is tricky. Isn’t it?

Happy coding. :D

Note: Write fully qualified class name (for our example “net.cavdar.staticinitializer.HelloWorldWithoutMain”) for configuring run options for main class, if you need.

Posted in Java, Tips & Tricks.

Tagged with , , , .