Eclipse useful tips and tricks

This 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!

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.

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.

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.


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.


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.

Why do I get the error “This compilation unit is not on the build path of a Java project” ?

If you see the error message “This compilation unit is not on the build path of a Java project.” it’s likely that your project file is missing the Java nature. Open the .project file and check that the Java nature is included in it. As an example, the following .project file holds the correct configuration for a Maven+Java project:

<projectDescription>
    <name>myproject</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
    </natures>
</projectDescription>

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.

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.


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.

How to find quickly anything in Eclipse

One of the new-and-noteworthy features in Eclipse is Quick Access . Even if you’re a fan of the mouse, this keyboard shortcut can save time and money.

The Quick Access -which is activated by Ctrl + 3– is your window to anything; perspectives, views, open editors, commands, menus … just start typing, and it will show you the possible matches. It filters the most likely ones first, but if you press it again, will show all the possible matches that it knows about.

This is the quickest way to fine ANYTHING oin Eclipse.

How to open an Eclipse file from Windows Explorer 

Sometimes it can be necessary to operate on your project files from the Windows Explorer. The less efficient way to achieve it is by
selecting the file properties, copying and pasting the file name in an Explorer window.

There’s an easy way to do it, by configuring Explorer as External Tool.

In order to do it: Create an external tool with location ${env_var:SystemRoot}\explorer.exe and arguments /select,${resource_loc} .

Any selected file or directory can now be shown in the windows explorer.

How to check the history of a file

Well, every real world project should be committed on a repository like SVN or CVS. Eclipse however has its own repository containing the history of your files.
This can be very useful to revert changes when necessary….or just in case you forgot to commit the file on the repository!

To use this feature, right click on the file of your choice and click Compare With -> Local history. That should open up the entries in the €˜History€ view.

Clicking on any of the history entries will open a diff window telling you the difference between the current entry and the previous edits.

Use Templates !

Templates are one of the greatest time savers for Eclipse developers, yet not all users are aware of them. A template is a block of text which can be inserted in your code. It’s much more powerful concept than cut and past since it may contain some dynamic pieces of code as well.

To see the list of built-in templates and to define new ones go to Window -> Preferences. Select Java -> Editor -> Templates. You can add your own templates here.

How to trigger a template: simply type in your editor the template code and press ctrl+space. For example type if you have defined a template named sql, just type sql and ctrl+space to activate the template.

Code template variables:

Eclipse can automatically fill out dynamic code by sniffing out variables in a template. Here are a few you should make yourself aware of

${cursor} - Place the cursor here after code completion
${enclosing_method} Replace this with the method name where the code completion was called.
${enclosing_method_arguments} Replace this with the enclosing method arguments
${enclosing_type} The enclosing class name
${import} Dynamically import some classes
${importStatic} Same as above but with static imports
${time} Current time

And here are a few interesting templates which can be imported in your project:

Singleton Template:

private static ${enclosing_type} singleton = new ${enclosing_type}();

private ${enclosing_type}(){
}

public static ${enclosing_type} getInstance(){
  if(singleton == null){
    singleton = new ${enclosing_type}();
  }

return singleton;
}

Log4j Template: (Defines a logger for the current class)

${:import(org.apache.log4j.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class);

How to set the proxy address in Eclipse

Well, most developers use Eclipse at work behind a proxy so it’s absolutely a must to configure the proxy for keeping your libraries updated. Well the good news is that newer releases of Eclipse are able to read your browser’s Proxy configuration, so it should work automatically.

If you have got an earlier Eclipse release or simply you want to customize your Proxy configuration, just point to Window > Preferences. Under the General element you can find the Network Connections panel which contains the proxy configuration.

Choose “Manual” to provide a custom proxy configuration. In the bottom part of the screen, you will be able to exclude the addresses which you don’t want to hit with your proxy.

Getting started with Red Hat Code Ready Studio

JBoss Developer Studio is a free tool for developing applications with JBoss products, such as JBoss EAP/WildFly or Quarkus.

JBoss Developer Studio has been now renamed to Red Hat Code Ready Studio and it’s available for download at: https://developers.redhat.com/products/codeready-studio/download

Please note that to download this product, you must have a Red Hat account and accept the terms and conditions of the Red Hat developer program, which provides no-cost subscriptions for development use only.

Installing Red Hat Code Ready Studio.

You can either install it through Eclipse Marketplace as plugin, or donwload the standalone installer and install it with:

java -jar codereadystudio-12.17.0.GA-installer-standalone.jar

Once installed, you can run it as follows:

$ ./codereadystudio

Connecting Red Hat Code Ready Studio to WildFly

To connect to WildFly using Code Ready Studio, you must direct the IDE to the local or remote runtime servers. This establishes a communication channel between the IDE and the application server to ease deployment and server management. In order to do that, choose “New | Server” from the upper menu and expanding the JBoss Community option. Pick up the latest version available of the Server plugin:

Note: In your first Server definition, you will have to Add a Runtime environment to your server by clicking on the Add link and selecting your application server home.

Click on Finish to complete your server installation. Now you should be able to use the **Start/Stop** button on the Server tab to trigger the server startup and shutdown. The tiny beetle icon can be used to Debug your applications, and besides it a watch button that can be used to **Tune** the application server.

Remote debugging with Red Hat Code Ready Studio

Remote debugging is a key feature that is necessary to track issues on your server side applications. In order to activate remote debugging on the application server a set of JVM arguments needs to be enabled at application server startup:

-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n

Luckily, Code Ready Studio does it for you transparently, therefore it’s enough to start the application server in debug mode. Let’s see in a few simple steps how to do it:

Set up a break-point into any of your server side classes. Then start up the application server in debug mode and target your application on WildFly application server, by choosing the Add and Remove option available by right-clicking on the WildFly Server. Then, as soon as your application hits a breakpoint, you will be notifiedby Eclipse which suggests a change of perspective, stopping the execution at the breakpoint.

Which IDE to choose for JBoss and WildFly ?

This article describes which are the best IDE available for developing Enterprise applications with WildFly or JBoss EAP. We will focus on Development Environments which are free or have a Community version available.

Eclipse

Eclipse is one of the most widely used integrated development environment (IDE) to build software applications. Featuring a rich IDEs in the Java programmer community, also supports all major programming languages like Java, C/C++ and Python.

In terms of popularity, it’s a popular choice for developers of the JBoss.org community thanks to the JBoss Tools set of plugin for JBoss products. Actually JBoss Tools is a project which encapsulates a set of Eclipse plugins that supports almost all JBoss and related technology; besides the Application Server, there is support for Hibernate, Drools, jBPM, JSF, (X)HTML, Seam, Maven, Camel, Quarkus and even more.

A detailed tutorial which covers JBoss Tools installation on Eclipse is available here: Configuring Eclipse to use WildFly (2021)

On the other hand, Eclipse is not just for WildFly users but it can be used for a variety of projects. For example, it is commonly used to design jBPM processes.

Check this article for more details: Design jBPM Processes with Eclipse designer plugin

On the other hand, if you would like a cloud-ready Eclipse you can try Red Hat Code Ready Studio (formerly known as JBoss Developer Studio) which is the quickest way to develop and test JBoss projects on a Kubernetes or OpenShift cluster. Behind the hoods, Code Ready Studio is an Eclipse based environment with includes JBoss Tools with extra features that aim to simplify the development of container-based services.

Check this article for more details about Code ready Studio check this article: Getting started with Red Hat Code Ready Studio

Pro: Advanced support for modeling.

Eclipse is the only IDE which supports modeling for a large set of JBoss projects.

Pro: Cloud friendly:

If you are planning to design and develop applications for Kubernetes based Cloud platforms, Eclipse is a real asset.

Cons: Performance and stability

Eclipse has a tendency to run slower than other IDEs. Overall as the number of plugins increase, the performance and stability of the environment will reduce quite a bit.

Cons: not so developer friendly

Unless you use a very basic version of Eclipse, with the least amount of plugins installed, the amount of options/views can overwhelm the developer.

IntelliJ Idea

IntelliJ IDEA is an IDE written in Java for developing computer software. It is developed by JetBrains, and is available as an Apache 2 Licensed community edition, and in a proprietary commercial edition.

This IDE has gained popularity thanks to some features  like code completion by analyzing the context, code navigation which allows jumping to a class or declaration in the code directly, code refactoring, code debugging, linting and options to fix inconsistencies via suggestions.

Overall, if you don’t need the JBoss Tools project to develop your Enterprise applications you will find IntelliJ just as good as Eclipse.

In this tutorial we discuss the options you can use to integrate IntelliJ Idea with WildFly: Developing applications with IntelliJ Idea and WildFly

Pro: Easy to get started

IntelliJ gives you what you need out of the box. You won’t need to spend some time customizing an environment for your needs.

Pro: Popularity

The popularity of one IDE over another should not be your only criteria for choice. However, the size of the community and number of fans among Java developers can have impact on productivity and ease-of-use.

Con: Limited Support for Modeling

IntelliJ has a large set of plugins (not comparable to the huge ecosystem of Eclipse): some of them allow you to bootstrap your projects, such as the Quarkus plugin. There’s also a plugin to assist you in coding Camel Routes however there’s no support for modeling things like BPM.

NetBeans

Apache NetBeans is a Community powered tool which runs on JDK LTS releases 8 and 11, with experimental support for JDK 17.

The good thing about NetBeans is that it’s ready to use out of the box. No extra plugins or extensions are necessary to increase usability. Since it is open source, there are thousands of other users that can help contribute to projects and concepts.

In terms of JBoss / WildFly integration you can easily add a WildFly server to your list of services and start/stop/debug it out of the box:

Read more about NetBeans and WildFly integration .

Pro: Developer friendly

NetBeans is a beginner-friendly IDE with a simple user interface. And you can get started without all the plugins: simply add a built-in WildFly server to manage it.

Pro: Stability

NetBeans is quite stable. This is also because you don’t have to install lots of plugins. Also debugging with NetBeans is simpler and less prone to JVM crashes.

Con: Lacks Support for Modeling

NetBeans has improved quite a lot in stablity but has never added any support for modeling applications. Maybe for this reason its popularity has faded in recent years.

10 Eclipse tricks you should know

Our collection of Eclipse Tips and Tricks keeps growing: Here are some more Eclipse Tips and Tricks you should know!

#1 How to list all eclipse shortcuts

How to display a list of all the keyboard shortcut combinations: Ctrl+Shift+L

#2 How to run multiple JVMs in Eclipse.

If you launch multiple JVMs you’ll have the “Display Selected Console” (2) activated. When you choose this option you can select from any of your running applications. Just select the tab, select which application you want it to watch, and repeat for the other tab.
Hint use the Pin Console button (1) to ensure that the current console remains on top of all other consoles.

#3 How to turn a String into a System.out

Highlight (or select) a Text. Press Ctrl+Space. Hit End+Enter. the “sysout” snippet is triggered which wraps the selection around as its parameter.

eg. “hello world!” becomes System.out.println(“hello world!”);

Also if you type ‘syso‘ then press Ctrl+Space to expand it to:

System.out.println()

#4 How to assign a variable/field quickly

Instead of typing:

MyClass c = new |

(| is cursor location):

just type

new MyClass()|

and press Ctrl-2 L, which results in:

MyClass c = new MyClass()|

This really speeds things up. (Ctrl-2 F does the same, but assigns to a new field rather than a new variable.)

#5 How to find the Class hierarchy for a method

Click on a class or method name and press Ctrl+T.

You get a quick type hierarchy. For a class name you see the entire class hierarchy. For a method name you get the hierarchy showing superclasses and subclasses, with implementations of that method distinguished from abstract mentions, or classes that don’t mention the method.

This is huge when you are at an abstract method declaration and quickly want to see where it is implemented.

#6 How to wrap long String literals

You can have String literals wrapped when you edit them. For example, if you have code like this:

String message= "INTO USR_USERS_WO_NOTES_STATUS(STATUS_ID, NAME, DESCRIPTION) VALUES (100, 'PUBLISHED', 'Pubblicata');";

position your caret whereever you like in the String and press Enter. The code will be automatically changed to:

String message= "INTO USR_USERS_WO_NOTES_STATUS" +
                "(STATUS_ID, NAME, DESCRIPTION) VALUES " +
                "(100, 'PUBLISHED', 'Pubblicata');";

This behavior can be customized in the Opens the typing preference page Java > Editor > Typing preference page.

#7 Exception breakpoints

One of the very cool things many people don’t know about Eclipse is that it will let you set breakpoints based on where an Exception occurs. This is going to be a huge timesaver! You access the option via the “j!” icon in the debugging window.

In the resulting dialog:

In the Choose an Exception field, type a string that is contained in the name of the exception you want to add. You can use wildcards as needed (“* ” for any string and “? ” for any character).
In the Matching types list , select the exception you want to add.
Select Caught and Uncaught as needed to indicate on which exception type you want to suspend the program.

#8 Use content assist

You can use content assist to speed up the creation of fields, method parameters and local variables. With the cursor positioned after the type name of the declaration, press Ctrl+Space.
Ex. List [Control / Space ] will add:

List list;

You can exclude certain types from appearing in content assist, use the type filter feature configured on the Opens the type filter preference page Java > Appearance > Type Filters preference page. Types matching one of these filter patterns will not appear in the Open Type dialog and will not be available to content assist, quick fix and organize imports. These filter patterns do not affect the Package Explorer and Hierarchy views.

For example, it’s quite annoying if you are developing server based applications and you have several List class availables. You can filter out classes like java.awt.List which will not be suggested anymore.

#9 Eclipse is Camel case aware!

Eclipse IDE is aware of CamelCase. You can type class names faster by only typing the upper-case letters:

This also works for method names – very convenient for getter and setter methods.

#10 Tweaks to eclipse.ini

I’ve had a noticeable improvement in startup time and overall response times on my Eclipse installation by adding the following to eclipse.ini, at the bottom:

-Xincgc
-XX:-DontCompileHugeMethods
-XX:MaxInlineSize=1024  
-XX:FreqInlineSize=1024

Also, tweak the Xms (initial heap size) and Xmx (maximum heap size) to higher values, depending on your RAM and the number of other running applications.

Do you want more Eclipse tips and tricks ? read Eclipse useful tips and tricks

Develop your Enterprise applications on the Cloud with Eclipse Che

This tutorial is an introduction to the Eclipse Che cloud development tool which allows to build Enterprise applications without leaving your browser.

If you land in the Eclipse downloads page, you will see that several options are available, besides the standard installer. One of this option, named Eclipse Che is a cloud environment is focused on container-native development. It defines workspaces that include their dependencies including embedded containerized runtimes, a web IDE, and project code.

Let’s see a quick example of how it works. Start reaching Eclipse Che page, available at: https://www.eclipse.org/che/getting-started/download/

From there, you have two options:

 

The first one will allow you to run Eclipse Che within your browser without any installation, the second one allows installing Eclipse Che on your machine to work as development server. Let’s choose the first option.

if you opt to use Saas development, then you need to choose how to get started. You have three options:

  • Get started by creating a workspace using a wizard
  • Directly start by providing a GitHub or GitLab repository which will be cloned in your development environment
  • Use a template starting from oen of the many options available

We will go through the simplest option for a developer, that is starting from a GitHub project. Enter a valid GitHub repository.

For example, I will use a repository I have created time ago to test a Web application on Openshift: https://github.com/fmarchioni/openshift-jee-sample

In a few minutes, A Container image of your project will be created and you will be able to edit the project from within the browser:

At the bottom of your editor, a tab panel contains a Terminal window from where you can execute build commands on your project:

Once built, you can download the artifact to your Host machine:

That is a good option if you need a quick edit, rebuild and download of your project. Most of the times, however, you would like to let a Continuos Integration Tool (like Jenkins) to manage the build and deploy of your project. For this reason, you would like rather to learn how to commit and push the changes to the repository from Eclipse Che.

 

In order to do that, Reach the Profile->Preferences option and select VCS from the Menu. We will need to create a public key which will be uploaded on GitHub (or any other repository). Therefore Click on Generate Key and enter as Host “github.com”.

The generated key needs to be added in your GitHub Settings as showed by this picture:

As side note, I had to click on the Github icon which is next to your Profile Preferences, to enforce Eclipse Che to upload the SSH key to Github, otherwise my pushes to remote repository kept failing:

Once done that, you are ready to work with your team by using Eclipse Che.

Now, you can check out a project, perform the required commits (Git->Commit):

Then, when you are ready, Push the commits to the Remote Repository (Git->Remotes->Push)

And you are done! Enjoy could development with Eclipse Che!

Eclipse search Tips

Want to have everything at your fingertips with Eclipse ? this tutorial provides some handy tips to search and find what you are looking for in Eclipse.

How to search in a specific Eclipse project

If you have lots of open projects in your workspace then you would like to search in a specific project.
Solution: Create a working set . Working sets group elements for display in views or for operations on a set of elements.

Open the Search Menu and click on the “Choose” button to create a new Working Set:

Next, choose New to create a new Working Set :

In the next screen, select “Resource”:

Pickup one or more projects from your Workspace which will be part of your Working Set:

Now you can use the New Working set in your Searches:

How to search for a class/package in a set of JAR files?

Provided that you are using the JAR files in a project as a library, then you can use the powerful Java search. Here’s for example how to find where the org.apache.cxf.Bus class is contained :

Depending on what is searched for, the search string should describe the element:
Type: the type name (may be qualified or not).
Example:    org.apache.cxf.Bus

Method: the defining type name (may be qualified or not as for Type search, optional), the method selector and its parameters
Example:  org.eclipse.jdt.internal.core.JavaElement.getHandleFromMemento(MementoTokenizer, WorkingCopyOwner)

Package: the package name for a package (e.g. org.eclipse.jdt.internal.core

Constructor: the defining type name (may be qualified or not as for Type search, optional) and the constructor parameters

Example: org.eclipse.jdt.internal.core.JavaElement(JavaElement, String)

How to find all classes that extend interface

Simply use Ctrl-T to get the descendants and then Ctrl-T again if super interfaces/classes are wanted:

How to replace String in all files in Eclipse

Not everybody is aware that you can perform safe Search and Replace string patterns across a set of files. I mentioned “safe” because you are allowed to preview changes before executing the replace.

  1. Go to the Menu “Search”->”File”
  2. Enter text, file pattern and projects
  3. Click “Replace”
  4. Enter new text

How to exclude folders from Eclipse search

The simplest way to exclude a folder is: right click on a folder, go to properties, and mark a folder as derived. Derived

How to share the eclipse search result/ query

Have a look at the Mylyn project (http://eclipse.org/mylyn).

Mylyn is the task and application lifecycle management (ALM) framework for Eclipse. It allows you to create tasks and send them to co-workers through a task repository (such as bugzilla, jira, or most major issue trackers). Attached to these tasks are “contexts”, which associate code elements (methods, fields, classes, etc) with the task.

Here are the steps needed to get started:

  1. Install mylyn (you and all co-workers)
  2. Install the proper Eclipse Connector for your issue tracker (such as SVN Eclipse connector).
  3. Now add the task repository to your Eclipse. This is the way that mylyn speaks to your issue tracker. It allows you to create issues, bug reports, tasks, etc, from within Eclipse.
  4. With this set up, you can now create a task associated with a task repository and activate it. You can add the desired program elements to your task by right clicking -> Mark as Landmark.

How to export/save Search Results

Out of the box there is no Save search functionality, however you can use the “Show Previous Searches” button at the top of the search console. It has a flashlight with a list above it. You can toggle between searches and Eclipse has already done all the heavy work.

Eclipse JPA Editor tutorial

The JPA Diagram Editor is a graphical tool based on the Graphiti framework that enables the JPA developers to create, view, and edit their business data model as graphical diagram.

JPA Diagram Editor is compatible with Indigo and later releases of the eclipse. (Including Helios and Juno).
From the JPA specification point of view, JPA diagram editor offers full support for JPA 1.0. JPA 2.0 support development is in progress as well as support of additional JPA artifacts like embeddable classes and mapped superclasses.

The simplest way to use this plugin, is to enter Eclipse MarketPlace and look for it (Hint enter JPA in the Find box and choose to install the JPA Diagram Editor):

Features:

  • The JPA diagram editor comprises the following general features:
  • Ability to create entities and define relationships between them.
  • Ability to import existing entities together with their relationships.
  • Full synchronization with the underlying application code, that is, whenever you apply a change to any of the objects on the diagram, the corresponding application code updates automatically, and the opposite.
  • Error and warning markers with informative quick info text. You can view details on the marked errors and warnings in the Problems view.
  • Integration with the JPA Details view and the Miniature View.

Prerequisites:

You need to have:

  • Created a JPA project to store your entities
  • You have a Non-JPA project but you enabled the Java Persistence facet on that project

How to open the JPA Diagram:

The Open Diagram action is available on project level: Select the newly created JPA project and from its context menu select JPA Tools -> Open Diagram

  Trick: You can open the JPA diagram also at JPA node level: Expand the   JPA project and from the context menu of its JPA node, select Open Diagram.

How to create a new Entity using the JPA Palette:

From the right site of the editor, the so called Palette section, select Java Entity and drag&drop it to the diagram. A new entity class org.persistence.Entity1 with default primary key attribute should be created and shown in the diagram. By right-clicking on the icon, you can rename it and add attributes to your Entity.

  You can change the default settings for your Entities by entering the Project Properties | JPA Section. There you can define the default package for your Entities, the Collection used by default for Relationship and lots of other settings.

How to see the Entities you have already created in the diagram:

If you want to visualize existing Entities in the diagram, simply open the JPA Diagram and drag and drop the Entities from the project into the Diagram.

 Hot Trick: How to show all the existing Entities you have in one shot ? simply right click on your JPA Diagram and select “Show all Entities


{loadposition jpaeditor}

The above video is a short demo of the capabilities of the JPA Diagram Editor – a graphical tool for JPA developers using Eclipse IDE.

How to install JBoss server in Eclipse

Installing JBoss / WildFly server in Eclipse

In this tutorial we will cover all the steps to install Eclipse IDE and, on the top of that, we will install the JBoss Tools so that we can start/stop/debug WildFly application server without leaving your IDE.
First of all, let’s get to the Eclipse main download page which is at: https://www.eclipse.org/downloads/packages/
As you can see, there are multiple solutions for developing applications. The latest version of Eclipse, requires a simple installation on your machine. If you are interested in developing Enterprise application using an Eclipse Cloud Solution, then take a look at Eclipse Che: Develop your Enterprise applications on the Cloud with Eclipse Che

In this tutorial we will show how to use the latest version of Eclipse to get started with developing applications on JBoss EAP / WildFly and Eclipse.

Step 1: Install Eclipse

The first step is to download the Eclipse installer from: https://www.eclipse.org/downloads/

Run the eclipse installer:

$ eclipse-inst

Then, choose the version of Eclpse to install:

The “Eclipse IDE for Java Developers” will install a minimal version of the IDE for developing Java applications with Maven/Gradle integration. If you want some extra tooling for developing applications, such as JPA and Data Tooling, choose the “Eclipse IDE for Enterprise Java Developers”.

Once down with the download, launch eclipse.

Step 2: Install JBoss Tools

JBoss tools is a set of subprojects which are related to JBoss products: for example you can use JBoss AS Tools to create, deploy and debug applications on JBoss AS. The Hibernate tools can be used to simplify mapping and querying your data with Hibernate. The Seam tools can be an handy guide to develop applications with JBoss AS Seam project, and so on.

We will now show how to install JBoss AS Tools on Eclipse. There are several ways to install Eclipse plugins: basically this boils down to intalling the plugin from within Eclipse environment and downloading and manually installing the tools. The simplest way to do it is through the Help | Eclipse Market Place and enter in the search box “JBoss Tools”. You will see several JBoss Tools releases available. Choose to install or update the latest stable JBoss Tools plugin:

If you are working with the supported version of JBoss products, then it’s recommended to install Red Hat Code Ready studio which will bring in your IDE all the required tools to develop applications with Red Hat middleware.

In the next screen select the “JBoss AS tools” plugin and restart Eclipse once completed. Now choose from the upper Menu: File | New | Server and expand the JBoss Community option. A set of “WildFly” Servers are included:

In the next screen you have to choose if the Server is locally installed (Local) or it’s a remote server (Remote) and how the Server Lifecycle is managed:

Finally, point to the location where the application server is installed, the JRE execution environment and the configuration file to be used (default is standalone.xml) :

Click Finish. WildFly is now configured on your Eclipse environment!

Ok, at this point you should find out in the Eclipse tool bar the following three icons:

This icon (1) can be used to select the server version in case you have installed multiple AS version
This icon (2) can be used to boot the application server
This icon (3) can be used to debug the application server

Additionally, you can choose from the Menu: Window | Show View | Server
The following tab GUI will be accessible to start/stop/debug and deploy applications on JBoss AS.

Let’s try to start the server. Right click on the Server icon and choose “Start” from the Menu.
The Console Tab GUI will activate, showing the server boot logs. At the end of the process, the Console will display f the server started correctly.


Deploying an application to JBoss AS / WildFly with Eclipse

Deploying an application is quite easy and just requires right clicking on the Server icon and choosing “Add and Remove“. In the next GUI choose a Java EE application project which will be deployed to JBoss AS and click on “Add” and “Finish“.

Fine. In a few seconds your application will be available on JBoss AS.

How to debug your applications running on JBoss AS / WildFly.

The simplest way to debug your Java EE applications on JBoss AS / WildFly is starting the server from within Eclipse in Debug mode. Simply right click on the Server icon and choose “Debug“. Once that the compiled code hits a breakpoint, the Debug perspective view will kick in.

The other way to debug, is called remote debugging and happens if you are running JBoss AS on a separate process. In order to remotely debug JBoss AS, set this properties in the AS start script (standalone.conf):

JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"

In the Debug configuration, create a new Remote Java Application node.
In the Connection Properties, specify localhost as the Host and specify the Port as the port that was specified in the run batch script of the JBoss server, 8787.

Please note that WildFly and JBoss EAP use deployment marker files to trigger deployment of applications. By default packaged archives are automatically deployed. On the other hand, exploded archives require a marker file named application.dodeploy to trigger deployment: for example if you are deploying an explodec application named Example.war, then you need creating a file Example.war.dodeploy in the deployments folder.

XML auto completion with Eclipse

This short tutorials shows how to activate some interesting features on Eclipse when dealing with XML files.

If you have been struggling with XML files based on complex schemas you might find tedious to check the .xsd files or some examples every time you had to modify your XML. Rinzo is an Eclipse xml editor with the goal of make life simpler when dealing with xml files.

You can install it with a few simple steps. Go to Eclipse Market Place and search for the Rinzo Plugin.


Once installed you will be prompted to accept the terms and conditions and eventually to restart Eclipse.

At restart you can enjoy the rich set of new features which include:

* Autocompletion of tags and attributes, proposing the ones defined in the file’s DTD or Schema.
* Xml validation using DTD or Schema, DTD and Schema generation from a xml
* Namespace support.

This makes it very useful if you must edit a web.xml , .hbm files , struts-config or any other xml file provided that, of course, you have specified the location of your .xsd files within your XML document.

Eclipse Web lib configuration

Eclipse has used different configuration steps to add libraries to Web applications. This tutorial shows how to configure them with Eclipse Galileo, Helios and Indigos.

 

 

When using Galileo (or earlier) Eclipse releases, exporting libraries to the WEB-INF/lib folder of your Web application could be done by means of the Java EE Module dependencies option. Right click on your project and select “Java EE Module dependencies

 

When using Helios or Indigo you can use a more fine-grained approach which let you add libraries from a the build path or from a static location even from other projects.

Right-click on the project Properties and select “Deployment Assembly“.

From there, choosing the “Java Build Path Entries” option will automatically export your Build Path into the WEB-INF/lib folder of your web application.

Alternative approaches:

1) Enable the “Problems” view. You will see that libraries added to the build path, but not exported are marked as a warning. Right-click on the library and choose “Quick fix

then “Mark the associated raw classpath as entry …..”

2) At last, you can manually copy/drag your libraries in the WEB-INF/lib folder of your Project Explorer and they will be automatically exported in the same location in your war.