IcedTea-Web/DevelopingWithEclipse

From IcedTea

Jump to: navigation, search

Contents

1 Prerequisites

Before we get started, please make sure you have a build of Icedtea-Web. Refer to Getting IcedTea-Web if needed.

2 Adding source to Eclipse

2.1 Step 1 - Creating a new java project

Our very first step will be to create a new java project that we can use to add IcedTea-Web's source. If you want to use an existing project, you are welcome to skip this step.

To create a new project: click File -> New -> Java Project. You should see a dialog like this:

Type in a project name (in our case, we will call it "IcedTea-Web"). Ensure that you are using a JRE that's Java 1.7 or later (this example is using IcedTea7) and click Finish.


Note: If you would like to add additional JREs in Eclipse, you can use the 'Configure JREs' button in the dialog and follow the steps to set it up. For IcedTea7, the JRE path is /path/to/icedtea7/build/linux-amd64-debug/j2sdk-image/


2.2 Step 2 – Adding source

Now that we have a project to work with, we are ready to link the source.

Right-Click Project -> Build Path -> Link Source. Click Browse and navigate to /path/to/icedtea-web/netx/ and click OK. In the "Folder name" textbox, type in the name of the folder which you wish to add the source under. In our case we will call it: 'NetX'. After you have completed this, you will see a dialog like the one below. Click Finish.

You will see that a new folder has been created to your project with the content of the linked directory.

Repeat this step to add:

Source Name Location
Unit Tests /path/to/icedtea-web/tests/netx/unit/
Plugin /path/to/icedtea-web/plugin/icedteanp/java/
Test Extension /path/to/icedtea-web/tests/test-extensions/
Test Extension Tests /path/to/icedtea-web/tests/test-extensions-tests/

Note: The source may contain errors. These errors are visible due to missing libraries which the source uses. The next step will fix these dependencies.


2.3 Step 3 – Adding additional libraries

The sources we added in the previous step contain several errors. This is due to the fact that some of the libraries which the source uses are missing. Let's fix this by adding the two required jars: rhino.jar and junit4.jar.

Right-Click Project -> Build Path -> Configure Build Path

The 'Java Build Path' dialog will appear. Click Libraries tab -> Add External JARs

Add the following two jars and click OK to close the dialog when done:

Jar Name Default Location
junit.jar /usr/share/java/junit4.jar
rhino.jar /usr/share/java/rhino.jar

3 Debugging Java Web Start Applications and Applets In Eclipse

3.1 Configure Eclipse for Remote Debugging

Right-Click Project -> Debug As -> Debug Configurations

A configuration window will appear. From the list, Right-Click "Remote Java Application" -> New

Confirm the information provided is correct. Change the name to "IcedTea-Web Debug Mode", change the port number to 8787, and keep the host localhost. You should have something like this:

Now click Common tab and check 'Debug' so this option appears in the Debug menu.

After hitting Apply to save settings, close the dialog. Confirm that the debug option is visible under the debug menu.


3.2 Debugging Web Start Application

One of the very first steps in debugging code is to create a breakpoints so our debugger knows where to start debugging from. Let's begin by creating a breakpoint in JNLPClassLoader's constructor.

Now, we are ready to begin debugging applications. For our example, we will be debugging Home Sweet 3D by running this command:

$ /path/to/icedtea-web/build/bin/javaws -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y -Xnofork http://www.sweethome3d.com/SweetHome3D.jnlp

Open Eclipse and select 'IcedTea-Web Debug Mode' from the Debug menu,

You're now debugging IcedTea-Web.


3.3 Debugging Applets Through Firefox

Debugging applets through Firefox is very simple. We start by setting debug mode to true when launching firefox:

$ ICEDTEAPLUGIN_DEBUG=suspend firefox

Note: You will need to close all running instances of firefox before executing the command above.

After executing the command, navigate to the webpage containing the applet you wish to debug and you'll notice firefox will hang. At this point, you need to go into Eclipse and select 'IcedTea-Web Debug Mode' from the Debug menu.

You're now debugging an applet in Firefox.


4 Running Unit Tests in Eclipse

It is very easy to run unit tests in Eclipse. You can run them by Right-Clicking the Folder, Package, Class, or even a method and going to Run As -> JUnit Test

Personal tools