Advertise with us

Search Mastertheboss

Our eBooks

Eclipse useful tips and tricks

Eclipse tips and tricksThis is a collection of Eclipse Tips and Tricks which I've learnt over time. You will be surprised how you can boost your productivity by learning just a few simple tecqniques! Feel free to post your tips at This email address is being protected from spambots. You need JavaScript enabled to view it. and I'll gladly publish them.


How to choose the format of deployed applications

In order to run this trick, you need to install JBossAS tool from JBoss tools distribution. Once you have installed this component, select the JBoss AS perspective.


eclipse tips tricks


In the lower part of the screen, double click on the server. The jBoss runtime window will open with two tabs.


Select the "Deployment" tab and choose if you want to deploy the application as compressed archive or not.

eclipse tips tricks tutorial

How to deploy an application to a remote JBoss server.


You need to to install JBossAS tool from JBoss tools distribution in order to run this tip.


1. From the File menu select New > Server and choose a JBoss server from the "JBoss Community" list.


2. In the next window will let you choose the local installation of JBoss server. This will be anyway needed for setting up the classpath of your project.


3. In the next window you will specify the location of the JBoss server. Choose as server behaviour "Remote system deployment" and select the Host using the "New Host" button.


eclipse tip tricks
4. Once connected to the host, choose the "Browse" button to browse the remote file system and pick up the JBoss home. If everything was correctly configured the "Test" button will verify the connection to the server.

How to debug JBoss remotely


Remote debugging of a Java application can be done using the Java Debugger (jdb) which is a dynamic, controlled, assignment-based debugging tool. It helps find and fix bugs in the Java language programs both locally and on the server. To use jdb in a J2EE application server you must first launch it with debugging enabled and attach to the server from the debugger through a JPDA port (Default port is 1044).

On JBoss, the debugger can be enabled by uncommenting this line in the file run.conf.bat (run.conf for Linux)

set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

After making sure JBoss is listening for incoming connections on port 8787, what is left is to tell Eclipse to connect to this port and you are ready to debug.

1. In Eclipse, navigate to Run > Debug  

2. Select Remote Java Application , on the left column. Click New , on the bottom of the same column.


3. In the Create configuration screen you'll be prompted to enter some values. Start with a meaningful name. For Project, select the Java project that contains the source code you want to debug. Leave Connection Type in default, i.e. Standard (Socket Attach) . For Host , enter the remote server hostname or IP address. For port, enter 8787 or the port you defined in your JBoss startup script.


jboss eclipse tips tricks
4. Click Apply


5. Make sure JBoss instance is running in debug mode. In the same screen click Debug . Eclipse should automatically take you to the Debug perspective and you should see a stack trace in the Debug view.


6. If you are not automatically taken to the Debug perspective, select Window > Open Perspective > Other and then click Debug.

How to use Ant to build your project

By default your project is rebuilt using the settins defined into your Properties | Build Path.
Sometimes you might find useful to use an Ant script to rebuild your project, so that you can use it even from outside the development environment. (A typical example of it could be using an Ant script for building both the development project and the production project).

At first open up the project properties to the 'Builders' section. Select the 'New' button and then in the next dialog choose 'Ant Build'.

In the 'Name' field enter the name you want to give the builder (Ex. Ant builder). Use the 'Browse Workspace' buttons to choose the location of the build file and the project root.
eclipse tips tricks
In the Targets tab you can configure the 'Clean' and 'Build' targets for your ant script. By convention, these targets are 'clean' and 'build'. For 'Clean' you will want the targets to clean the binaries and then rebuild the project. Once you have completed configuration, select 'OK'

Eclipse will now return you to the Builders section of the project properties dialog. Make sure that 'Java Builder' is is not checked in the list. Select 'OK' to apply the changes.

Eclipse tips tricks
Now you have a completely Ant based project, no Eclipse compilation involved.


How to add quickly all imports to your project


By default, when Eclipse encounter a class which has not already been imported, marks it with a red (+) to the user which can do a set of options (importing the class if it's in the classpath, define a new one, rename the class to one which is visible to the class).


Fixing this issue for every class reference is time consuming and often causes Eclipse to hangs for some seconds while it's elaborating all possible suggestions.

However there's a wonderful option called Organize Imports (Source > Organize Imports or Ctrl + Shift + O ) which automatically adds all imports to your classes.


If there are multiple Classes with the same name, a dialog will prompt to ask which Class you want to import.


© 2020 All Rights Reserved.

Please publish modules in offcanvas position.