Tag Archives: eclipse

Using Eclipse WTP for developing application under Websphere Application Server Community Edition (WAS CE)

This tutorial assumes that you already have Eclipse WTP (Galileo) and WAS CE (2.1) installed correctly. To make sure that your Websphere is installed correctly, start the server and go to the console. If you can do so, you’re in the right track. After that, just shutdown the server because we will manage the server from Eclipse.

After that, the first step is to install the Eclipse plugin for WAS CE. This plugin contains several things, and one of it is WTP server adapter for WAS CE. The update site for the plugin is http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/

Restart Eclipse like usual after installing the plugin.

Now we are ready to develop our first project under WAS CE. Create a new ‘Dynamic Web Project’. You’ll get something like this:


What’s important here is to change the Target runtime to ‘IBM WASCE 2.1’, so if you haven’t had one, you should create a new target runtime by clicking the ‘New…’ button. I think the creation of target runtime is pretty self explanatory. You just need to put the directory name of where you installed the WAS CE. This step is critical because if you don’t change the Target runtime now, the application can’t be run correctly from Eclipse.

After that, you will be asked to put the usual information for a dynamic web project but if click next and next, you will get a custom ‘Geronimo Deployment Plan’. Here you need to put the name of group id, artifact id, version, and artifact type. This information is needed because your application will be seen like a normal system resource, which can be a library or an web application.


After that you will get a new web project. What’s different in this web project is there is a geronimo-web.xml under WEB-INF and IBM WASCE 2.1.will added as referenced library.

You can start developing your web application and running it using normal way.

Eclipse Tips: Debugging your multi thread application (2)

This post is another tips of debugging your multi thread application. If you are interested on how to debugging a multi thread application, probably you will find my first post useful as well.

In a multi thread application, it’s still possible to use a certain class from different threads. The problem is if you try to set a breakpoint in this shared class, the breakpoint will be valid for all threads. This is typically just slowing our debugging session.

With Eclipse, you can set a breakpoint that only valid in certain threads. The catch is since there is no way that Eclipse knows what threads will be available, you can only set this on runtime.

To do this, you need to first set the breakpoint you want (remember, you probably need to Suspend the VM as well).

After that, you can start the debugging session and wait until the application is suspended. In this occasion, let open the breakpoint properties. In this window, there are two elements in the left tree: Breakpoint Properties and Filtering. Select Filtering and after that you can set to which thread the breakpoint should be valid for.


There are two more catches.

  • If the intended thread is not running yet, this method is not usable.
  • Every time the debugging session is restarted, you’ll need to filter it again.

Despite that catches, I think this is nice feature to know by multi-thread application developers and who know, it may be useful sometime in the future.

Eclipse Tips: (Debugging) Ignoring certain classes from being stepped into

Some of us may have encountered a not so nice experience where you basically got an strange result from a method and decide to step into that method as deep as possible. The problem is somehow you are lost in track and you can’t debug furthermore except if you’re exiting the debug mode or resuming the debug. Both are not the best solution because you have to inspect the application one more time.

The symptom of the problem is usually you a “Source not found” on your editor. If you are trying to ‘Step Return’ you are basically lost in track because you can not return to a class with source code.

For testing, you may try to write a log, for example:


If you’re trying to step into this method, you may get (since this obviously depends on your Eclipse configuration, you may also not get this screenshot):


Now try to ‘Step Return’ several times… do you still get the ‘Source not found’ message?


It’s actually easy to understand if you look at the debug view.

You are basically step into a long method calls, which most of them doesn’t have line information. Eclipse will automatically ignore these methods when you are stepping into. But then suddenly, it touched a method equals from class ‘Class’ which does have line information, but no source attached for it.

So, if you are patient enough, you can just do ‘Step Return’ several times (in this case about 16 times) and you’ll return to your class (with nice source code 🙂 ). This is obviously too much work.

One other alternative is to ignore certain classes to be stepped into. In Eclipse, the name of the functionality is called ‘Step Filters’. To use this functionality to ignore JDK classes, you have to configure Eclipse.

Go to the Preferences dialog, and open Java → Debug → Step Filtering.


Just ‘Select All’ and click ‘OK’. Now… If you are still trapped in the equals method, you can simply ‘Step Return’ and you’ll be back to your source code.

Once you’ve set the configuration in the Preferences, you can enable and disable this Step Filters anytime from your Debug perspective by clicking this button on Debug view.


Now… there is no reason to redo your entire debug session if you’re trapped in such situation.

Happy debugging!

Eclipse Tips: Auto generate ‘final’ on your variable, field, and parameter

If you are reading a lot of blogs about Java lately, you’ll find more and more people suggesting to use ‘final’ everywhere. The main argument is by using ‘final’ we will have a code with less bug. This post will not argue with the up/down side of the suggestion, if you eager to do that, just do that somewhere else (here for example).

However, if you are convince with such argumentation, probably the first thing on your mind is: should I now change all my code? How much time do I need to develop this instinct until all of my code is using ‘final’ everywhere?

Fortunately for Eclipse user, there is a functionality in Eclipse to help we develop this instinct. And it even will fixes our mistakes and we will get a consistent look of our code.

Let’s look at a code example:


There are some places where ‘final’ could be used. Now… open the Preferences dialog (under Window on Windows and Linux, under Eclipse on Mac). Navigate to Java->Editor->Save Actions.


Tick the ‘Perform the selected actions on save’ checkbox and ‘Additional actions’ checkbox. After that, click the ‘Configure…’ button.

What we’re interested in is in tab ‘Code Style’. Tick all ‘Private fields’, ‘Parameters field’, and ‘Local variables’. Click ‘OK’

Now you can go back to your source code and do small change, revert it back (Eclipse prevents saving if there is no change in the source code), and save it. Tarammm…. you get ‘final’ everywhere.


Note that this doesn’t put final on your method and class, you still have to do that manually.

Now you can enforce your team to use ‘final’ everywhere if you like!

My top Eclipse keyboard shortcut

eclipse logo

If you use Eclipse a lot you must have your favorite keyboard shortcut. Here are mine:

  1. Context Assist (CTRL+SPACE), I believe this is all favorite since they just have so many functionality. You want assistance about class name/method name/variable name. You get all. More than that, it also shows the template available for the context. It even suggests the possible variable name/method name. And it works in all places, even in the dialogs. This is a must know keyboard shortcut for all Eclipse user. Without it, you just will not get anything from Eclipse.
  2. Format (Shift+Ctrl+F), I usually type anything as fast as I can without bothering the format of the code. This shortcut will tidy up all the clutter and make my code readable.
  3. Save (Ctrl+S). OK, I know that this is a must for nearly all applications.
  4. Quick Fix (Ctrl+1). You get error or warning? Many times you will find that this shortcut can solve the problem for you.
  5. Rename (Ctrl+2+R). Since I’m a refactoring guy, I never escape from this task, renaming variables/methods/classes.
  6. Quick Type Hierarchy (Ctrl+T). Nice way to get information about classes tree without opening JavaDoc

So if you are also using Eclipse, what’s your favorite keyboard shortcut?