Eclipse Che – Getting Started

This is the second post of my Eclipse Che series. Today we are looking at the installation, configuration and the actual development with Eclipse Che. I recommend that you read my previous post since I’m using some terms I’ve explained there.

Eclipse Che is a cloud based integrated development environment (IDE) which can be used by developers to easily create applications without the need to install any application on their local system. Let’s get started by installing Eclipse Che on your local system.

Installation

Eclipse Che provides two ways of installation. One way is to install the pre-reqs on your own and just download a .zip-archive of Eclipse Che, the other way is an all-in-one installer which installs all necessary tools and applications before installing Eclipse Che.

Hint: By default, Eclipse Che – regardless which way of installation you choose – is configured to be a local IDE only. You cannot connect to it from a remote client.

Networking in Eclipse Che

Networking in Eclipse Che


Let’s look at the case that the Che Server is installed on a remote system. You can access the Server (including the dashboard and the IDE) using the IP of the remote server and port 8080. Behind the scenes the Server connects to the Virtual Box VM running on the same system using its IP and a port between 32766 and 65535. The Virtual Box VM responds to the server using the same IP as your client. Afterwards your client attempts to connect to the Virtual Box VM itself but since the IP of the VM is not accessible outside the remote system it cannot reach it. So you can connect to Eclipse Che, but you are not able to open any workspace. The following posts will give you an advice how you can set up Che to work on a remote system with multiple user access:

Custom Installation

If you’d like to do some configuration during the installation this is your prefered way to go. If you just want to try out Che as quickly as possible you might skip directly to the next section about the all-in-one installer.

Java

You’ll need to have at least a Java Runtime Environment (JRE) version 1.8 installed. You only need a JDK if you want to build Eclipse Che from sources. Make sure that your JAVA_HOME environment variable is set. See: Setting JAVA_HOME on Windows.

Docker Toolbox

It’s recommended to install the Docker Toolbox – not only Docker – since the Toolbox installs Git Bash and Virtual Box as well. The start script of Che is a bash script so make sure you have Git Bash installed. Virtual Box is used to run the Docker containers.

Download the .zip-archive

Download the .zip-archive, extract it and copy the eclipse-che-X.X.X to your preferred location. Make sure that the location does not contain spaces which might cause some issues.

All-In-One Installer

Eclipse Che comes with an all-in-one installer. If you choose this way to install Che you do not need to install any other software since the installer has all pre-reqs packaged and will install them before installing Che.

Starting Eclipse Che

Navigate into the bin folder of your Che installation and execute the che.bat file. Che will automatically launch a Docker container, and after its start-up you can connect to Che via http://localhost:8080 using a web browser. You’ll find yourself on the dashboard of Eclipse Che.

The Dashboard

Dashboard of Eclipse Che

Dashboard of Eclipse Che


The dashboard gives you quick access to recent workspaces and projects. You can create a new project by either clicking the blue New Project button (See: 1) or the plus (See: 3) in the upper right corner. By clicking the arrow (See: 2) you can create a new workspace. Using the workspaces or projects navigation item you’ll get into a dedicated list view.

Let’s create a new project!

Creating a project

Eclipse Che comes with a wizard to create projects and workspaces. In the project creation wizard, you can either create a workspace or select an existing one.

Project creation wizard of Eclipse Che

Project creation wizard of Eclipse Che

Select Source

You can either create a new blank project (See: 1) or import an existing one from external sources like a git repository, Github or a simple .zip-archive (See: 2). In our tutorial we are going to create a blank project.

Select Stack

A stack is just a pile of technologies which will be installed to your machine so you don’t need to install stuff manually. Eclipse Che comes with predefined stacks for Java, NodeJS, PHP, ASP.NET and even a blank stack (See: 3). In the Stack Library (See: 4) you can select more like vanilla systems like a blank Ubuntu or Debian. You are also able to create a new custom stack (See: 5) where you can write a Docker image file which will be used as a machine.

Configure Workspace

You can configure your workspace by giving it a name and setting the amount of RAM is takes at least (See: 6). Remember that a workspace can hold many machines and therefore might take a lot of RAM.

Select Template

Che comes with some Ready-to-run projects which include a hello wold (See: 7). You could either select one of these or create a Wizard-driven project. For our example we are going to create the console-java-simple project which is an easy hello world.

Project Metadata

The project metadata includes the name and a description of the new project (See: 8).

Create It!

By clicking the big blue Create Project button (See: 9) Eclipse Che will create the workspace and the project for you. You will be forwarded to the Construction screen where you can see the process of the workspace and project creation.

Construction Screen of Eclipse Che

Construction Screen of Eclipse Che


Creating and starting the workspace might take a little while, so be patient. When everything is done you are able to access the IDE and start developing.

The IDE

Let’s look at the IDE and the main functions we will need to get the development going.

A Screenshot of the Eclipse Che IDE

A Screenshot of the Eclipse Che IDE


The blue button on the upper left corner (See: 1) will take you back to the dashboard. In the toolbar (See: 2) is every functionality of the IDE categorized in dropdown menus. The tree on the left side (See: 3) equals the package explorer every IDE has. You’ll find your packages, classes, libraries and other files inside it. If you double-click any file, it’ll open in the editor (See: 4) where you can edit the file. For each opened file there is a new tab in the upper part of the editor. The toolbar above the editor can be used to execute the current project on the machine (See: 5). You are able to see the current default machine and select the run configuration (See: Run Configurations). Clicking the run button (See: 6) will execute your project with the selected run configuration. After you have executed the project the console will open automatically (See: 7) and you will get information about the current status of the execution.

Shortcuts

Che provides a lot of shortcuts for nearly every functionality that you need. If you are used to a local Eclipse version, you might run in some troubles since some shortcuts were changed to avoid native browser shortcuts like CTRL+SHIFT+O which will open the bookmark manager in Google Chrome. Fortunately, you will get a warning if for example you have unsaved changes in a file and hit CTRL+W which will close the current tab.

Run Configurations

Some sample projects are coming with predefined run configurations which you can use to build or run your project. If you are creating a project from scratch, you have to create them on your own. To do so you can click the dropdown (See: 5) and select Edit Commands.

Run Configurations in Eclipse Che

Run Configurations in Eclipse Che


Here we are able to manage our run configurations. In Eclipse Che your run configurations are just shell commands which will be executed in a given directory on your machine. Since we created a predefined hello world project Eclipse Che created two configurations for us (See: 1). We’ll have a closer look at our run configuration. You can edit the name (See: 2) of the configuration. The working directory (See: 3) should be set to the root directory of the project. The Command line (See: 4) contains the commands which will be executed inside the Working directory. In our case there are first some Maven tasks like clean and install. Afterwards the built .jar-file will be executed. The Preview URL (See: 5) has no effect for Maven project. It is used in projects which contain a web frontend and indicates where you can access the frontend.

Debugging a project

A common task for developers is to debug a project to find bugs by looking at specific values of variables during runtime. If you are used to work with a local Eclipse version, you know that you can run the debugger using a simple button. In Eclipse Che we will have to do some additional magic to start debugging.

First of all, we will create a new run configuration.

Debugging Configuration in Eclipse Che

Debugging Configuration in Eclipse Che


As you can see we are now using some Che variables to set the Working directory. This feature can be used to be able to run multiple projects using the same configuration. Our commands to enable debugging are very specific and include a lot of Java parameters:

clean install && java -jar -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y ${current.project.path}/target/*.jar

Save the configuration and set a breakpoint in your HelloWorld.java file by clicking the line number where you want the debugger to pause. Now select our debug run configuration in the dropdown and click the run button to start the application in debug mode. Your console log should contain something like this within the last few lines:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.657 s
[INFO] Finished at: 2016-04-20T09:49:37+00:00
[INFO] Final Memory: 15M/36M
[INFO] ------------------------------------------------------------------------
Listening for transport dt_socket at address: 8000

Now we can start the debugger by opening the Run dropdown in the upper toolbar and select Remote Debug. Another popup will ask you for a port for your debugger. Set this port to 8000 (we set the port in our run configuration with the address parameter) and click OK. Now we are done and the debugger should start.
The debugger of Eclipse Che

The debugger of Eclipse Che

Prospect

The next post will compare Eclipse Che and Eclipse Mars regarding the IDE. We’ll dive into the look-and-feel, the functionality, some issues and many more things you need to know to make a decision whether or not to use Che. Make sure you won’t miss it by subscribing this blog.

Short URL for this post: http://wp.me/p4nxik-2Bq
This entry was posted in Eclipse Universe and tagged , , , , , . Bookmark the permalink.

One Response to Eclipse Che – Getting Started

  1. Pingback: Eclipse Che | Blog

Leave a Reply