Archive for August, 2010|Monthly archive page

Contributing to JSDT #4 : Launching the unit tests

I’ll continue my instructions regarding how to set up JSDT development infrastructure.

Previously

Run the unit tests

Now I want to verify that the unit tests for JSDT pass.  (TDD — we should launch the tests before the product, right?)

Nitin Dahyabhai, the JSDT lead, pointed out that the first project above, contains a launch config to run all of the JSDT unit tests.

I will need to check out these additional projects from the webtools CVS repository.

  • org.eclipse.jsdt/development/org.eclipse.wst.jsdt.unittests
  • sourceediting/tests/org.eclipse.wst.jsdt.web.core.tests
  • sourceediting/tests/org.eclipse.wst.jsdt.web.ui.tests


The checked in launch config makes running easy.  Open Run Configurations – select JSDT Tests.  Hit Run.  They all pass, so I see green:

Next: Launching the Product

Disclaimer: I’m not on the JSDT team, so this may not be exactly how they do it. But it’s what I’ve done to get it working.

Contributing to JSDT #3 : Build Targets on the bleeding edge

I’ve been documenting how to use JSDT to do some HTML5/CSS/JavaScript development. In order to poke around the JSDT code to understand it better, I spent a bit of time figuring out how to get things checked out, built and running. The instructions on the JSDT site a re a bit sparse, so I thought I would document what I did.

I’m not on the JSDT team, so this may not be exactly how they do it. But it works for me.

Previously

My code no longer compiles!

This morning, I updated all the code I previously checked out.  And now my rhino.ui project has a compilation error in RhinoTabGroup:

After a little investigation, I determined that RhinoTabGroup is using a new 3.7 method in AbstractLaunchConfigurationTab.  It has just been introduced.  I’m building against Eclipse 3.6, so don’t have this method.

So if I want to keep my JSDT source code in sync with the latest, I’ll have to also keep up with any dependencies.

One idea to resolve this would be to download the latest milestone builds and put them in my build target.  However, this change is very recent and is not in a milestone build yet.

Another idea is to check out the latest o.e.debug.ui project and any dependency projects (hopefully not too many).

Check out more projects

To add the eclipse CVS repo, copy this into the CVS Repositories View:

:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse

And check out org.eclipse.debug.ui and org.eclipse.debug.core projects

And the compilation issue is resolved.

Going Forward

Going forward, my build target and workspace projects will change often.  I’ll need to actively modify these to keep things rolling along.  I’ll be doing a combination of:

  1. Including other Eclipse projects in my workspace, on an as-needed basis.  I’ll start getting a good sense of what these projects are as things break.
  2. Change my build target to move up to Milestone builds.

Next: Launching the JSDT Unit Tests

Contributing to JSDT #2: Checking out the Code

I’ve been experimenting with the JSDT to try some HTML5/CSS/JavaScript development.  In order to poke around the JSDT code to understand it better, I spent a bit of time figuring out how to get things checked out, built and running. The instructions on the JSDT site are a bit sparse, so I thought I would document what I did.

I’m not on the JSDT team, so this may not be exactly how they do it. But it works for me.

Previously

Adding the CVS Repositories:

Now we’ll add the 2 CVS repositories required to check out the JSDT code.

  • Switch to CVS Repository perspective.
  • Paste the following lines of text into the CVS Repositories View to add web tools and tools as known repository locations.

:pserver:anonymous@dev.eclipse.org:/cvsroot/webtools

:pserver:anonymous@dev.eclipse.org:/cvsroot/tools


Import the projects using a Project Team Set:

The JSDT project provides a project set file, which can be useful for checking out a set of related projects.  Download this to your file system.

In the Java Perspective, right-click in the Package Explorer and choose Import… – Team Project Set

Select Next, Choose the file you previously downloaded.

You will be prompted to reconcile the repos designated in the Team Project Set file and those in your workspace:

Hit OK.  The projects should be imported into your workspace and built.

Missing Projects:

If your projects don’t all compile, you may be missing a project or two.

Currently, the Project Team Set file is missing the debug.rhino.ui and debug.transport projects.  A bug has been fixed and I’m assuming the new project set file should roll out to the web-site in a few days.

You can check out these projects by browsing the webtools CVS repo from the CVS perspective:

Go to webtools / HEAD / org.eclipse.jsdt / plugins.

Right click on the project you want to check out and select ‘Checkout

Project List

With everything compiling and launching, I have the following projects in my workspace (as of 8/30/2010):

org.eclipse.wst.jsdt.core
org.eclipse.wst.jsdt.core.tests.compiler
org.eclipse.wst.jsdt.core.tests.model
org.eclipse.wst.jsdt.debug.core
org.eclipse.wst.jsdt.debug.core.tests
org.eclipse.wst.jsdt.debug.crossfire
org.eclipse.wst.jsdt.debug.rhino
org.eclipse.wst.jsdt.debug.rhino.debugger
org.eclipse.wst.jsdt.debug.rhino.tests
org.eclipse.wst.jsdt.debug.rhino.ui
org.eclipse.wst.jsdt.debug.transport
org.eclipse.wst.jsdt.debug.ui
org.eclipse.wst.jsdt.doc
org.eclipse.wst.jsdt.feature
org.eclipse.wst.jsdt.manipulation
org.eclipse.wst.jsdt.support.firefox
org.eclipse.wst.jsdt.support.ie
org.eclipse.wst.jsdt.ui
org.eclipse.wst.jsdt.ui.tests
org.eclipse.wst.jsdt.web.core
org.eclipse.wst.jsdt.web.support.jsp
org.eclipse.wst.jsdt.web.ui
org.eclipse.wst.jsdt_sdk.feature
org.eclipse.wst.jsdt_tests.feature
org.mozilla.javascript
releng.jsdt

Notes:

Updated: In the CVS repo some of the projects seem to live in both webtools/HEAD/org.eclipse.jsdt/<project> AND webtools/HEAD/<project>.  From some help on the forum,  I’ve found out these are one and the same.

Next: Build Targets on the Bleeding Edge

Contributing to JSDT #1: Setting up Build Target

I’ve been experimenting with the JSDT to try some HTML5/CSS/JavaScript development.  In order to poke around the JSDT code to understand it better, I spent a bit of time figuring out how to get things checked out, built and running. The instructions on the JSDT site are a bit sparse, so I thought I would document what I did.

I’m not on the JSDT team, so this may not be exactly how they do it. But it works for me.

Downloading Dependencies:

First you will need to set up your PDE Target.

The WTP Downloads page is where to start.

Download the following:

I unzipped these into individual folders, someplace where you keep pristine PDE targets separate from your daily running Eclipse. For example, I unzipped GEF into c:/code/buildTargets/GEF3.6.

Setting up the Target

Now, we’ll combine all these into a single PDE Build Target.

  • Under Preferences Plugin DevelopmentTarget Platform, select Add:

Select “Start with Nothing” , then Next.

In the Locations Tab, we will add each of the installed components from our buildTargets folder.    Select Add Directory Next – then Browse the location.

(Note: when selecting, choose the eclipse folder under each target.)

Do this for each of the 6 downloads above.

Then give your target a meaningful name such as JSDT_Target.

Then click Finish.

In the Preferences dialog, change the active build target to the new “JSDT_Target” and hit OK.

Now your JSDT code– which we have not yet imported–  will compile against the expected target platform.

Resources

  • Modular Mind has some great articles on PDE build targets.

Next: Checking out the code.

Using JSDT #3 : HTML5/JavaScript Workarounds

I’m documenting steps to use the Eclipse JavaScript IDE to work with HTML5/CSS/JavaScript.

Building on the previous post, this post will create a simple HTML5/JavaScript Canvas example using the Eclipse JSDT.  It will demonstrate some of the limitations I encountered using the JSDT for HTML5 and provide one workaround.

Update: Preliminary HTML5 support will be part of JSDT’s September 2010 release.

Previously

Using the HTML5 Canvas

We’ll use HTML5’s new drawing canvas.  If you want to learn more about HTML5 or Canvas, there are some links at the bottom of this page.

In this example, I’ve created a simple HTML5 page that draws 4 colored rectangles using JavaScript.

Create a new html file called canvas.html. with the following content:

<!DOCTYPE html>
<html>
  <head>
    <title>Canvas test</title>

    <!-- Pull in canvas support for IE -->
    <!--[if IE]><script src="excanvas.js"></script><![endif]-->

    <script type="text/javascript">
      window.onload = function() {
        var drawingCanvas = document.getElementById('canvas1');

        // Is element in the DOM and does browser support canvas
        if (drawingCanvas && drawingCanvas.getContext) {
          // Init drawing context
          var context = drawingCanvas.getContext('2d');

          // Create 4 squares
          context.fillStyle =   "#00FF00";  // Green
          context.fillRect(0,0,100,100);

          context.fillStyle = "#0000FF";    // Blue
          context.fillRect(0,100,100,100);

          context.fillStyle = "#FF0000";    // Red
          context.fillRect(100,0,100,100);

          context.fillStyle = "#FFFF00";    // Yellow
          context.fillRect(100,100,100,100);
        }
      }
    </script>
   </head>
 <body>
   <h1>HTML5 Canvas</h1>
   <canvas id="canvas1" width="200" height="200">
     <p>Your browser doesn't support canvas.</p>
   </canvas>
 </body>
</html>

JSDT’s HTML5 Limitations

The first thing I noticed is that JSDT is not HTML5 aware.

  • The editor has a warning marker in the gutter because the HTML5 canvas tag is unrecognized:

  • Hovering over pre-HTML JavaScript code, gets helpful (and slightly cryptic) API information.  However, try to hover over the newer drawingCanvas.getContext, and you don’t see any API info.

  • And the internal browser doesn’t support HTML5:
    • (To run inside the internal browser, Right Click canvas.html and select Run As – Run on Server)

Working around JSDT’s HTML5 Editor Limitations

I’m still trying to figure out the best way to get some nice HTML5 editor functionality (like hover help, content assist, etc), which is the primary reason I would use an IDE over a simple text editor.

Whatever I find out, I’ll post.  If anyone has experience with this, I’d love to hear about it.

Working around JSDT’s HTML5 Browser Limitations

It’s simple to work around the fact that JSDT’s internal browser does not support HTML5.  Simply switch to a different browser.

From in Eclipse, select Window – Web Browser – and then select either IE or the system browser.

In my case, the system browser is a recent version (3.6.8) of Firefox which has good HTML5 support.  I run it.  Success!

HTML5 Resources

There are many HTML5 resources available.  Here are a couple I used:

Next: Adding a 3rd party Library

Using JSDT #2 : Run First Project

I’m documenting the steps I’ve taken in using the Eclipse JavaScript IDE to work with HTML5/CSS/JavaScript.  Today, I’ll step you through installation and running a very simple HTML project.

Previously

Installation

The Eclipse JavaScript tools are called JSDT (JavaScript Development Tools).  You can get them several ways.  They come as part of the Eclipse Web Tools Project (WTP).  If you are already running Eclipse, you could use Update manager to install the JavaScript plug-ins into your current Eclipse installation.  I decided to download the JSDT product to keep it simple and see how well it worked by itself.

  • Unzip the download into a suitable location.  For simplicity, I unzipped into c:/jsdt.

Starting the product

  • Navigate into c:/jsdt/eclipse and double-click eclipse.exe to start the product.

(I’m using Windows.  The process is different but close enough that a user smart enough to use a different OS can figure it out.)

  • The first screen prompts you for a workspace.  I changed to default to c:/workspaces/html5.  Hit OK.

  • You should then see the JavaScript IDE, with no projects, ready to go.

Create HTML project

Now we’ll create a very simple static HTML page.

  • Select File – New – Static Web Project, and you should see this dialog:

  • Name the project simple and hit Finish.
  • Now select the simple project and right-click.  Select New – Html File:

  • Name the html file simple.html:

  • Hit finish.
  • Double click on simple.html to open it in the editor.  Change the title to “Simple Title” and enter “Simple” into the body.  Save it.

Test it inside Eclipse

Now we’ll test Simple using  server and browser provided by Eclipse.

  • Right Click simple.html and select Run As – Run on Server:

  • This will bring up this dialog.  Accept the defaults and hit Finish.

  • This will start a jetty server and open a browser view.  You should see the “Simple” page in the browser.

Next

The next entry will add some JavaScript and HTML5 functionality.

Using JSDT #1 : Resources

I’ve been doing some HTML5/CSS/Javascript programming lately.  I decided to take the JSDT (JavaScript Development Toolkit) for a test drive.

My plan is to document the steps I went through from installation through running some JavaScript from the IDE.

Today, I’m posting some of the more useful links I found when getting familiar with the project.

Download

The JSDT comes as part of Web Tools.  You could also use Update Manager to pull the JSDT plugins into an existing Eclipse.

I decided to download the JSDT product to see how well it worked by itself.

Resources for Users

Potential Problems?

While doing some research, I ran across several articles talking about the difficulty in getting the JSDT to integrate with 3rd party libraries.

I’ll find out more about this as I progress.

Resources for JSDT Developers

Next

Next I will step through the basics install JSDT, create and run an HTML page.

Senior Eclipse UI Developer Needed (Los Angeles)

I’m helping some colleagues find candidates for a senior UI developer at a Los Angeles based company.  Those with Eclipse UI or some other substantial UI experience would make great candidates.

The position requires the person to be in LA or to relocate to LA.

Please send your resume to scott dot kellicker at acm dot org.  (For full disclosure, I will receive a referral fee if you are hired.)

Qualifications:
• Experience in a front-end java development role at a commercial software company.
• Excellent understanding of core Java and web technology: J2SE, application servers and Spring
• Great experience in Java frontend technology (from templating languages to test automation)
• Good knowledge of front end technologies like CSS, HTML, JavaScript
• Excitement for the latest trends in web applications
• Superior creative and innovative problem-solving skills
• Initiative and the ability to work independently and in a team
• 3 years in front-end java development of commercially released software

Preferred skills
• Experience with JQuery, JSON, SWING, AWT, 2D, HTML5
• Experience with Agile/SCRUM/Lean software development
• Keen to learn more about new languages and frameworks
• Some experience with mobile development is preferable

Eclipse/JVM fails to start due to lack of memory

Lately, when starting Eclipse, the JVM has failed to start.  A reboot of the system usually fixed the problem.  Until yesterday.  So I had to dig in and solve this problem.

I wanted to share my experiences with debugging this issue.

Added Note: This is not the bug by which Eclipse running under java 1.6u21 fails to pass the permgen size on to the JVM.  If you are running java 1.6u21 with Eclipse, don’t.

Determine why eclipse.exe is crashing with “-debug”

I edited my eclipse.ini and added the -debug option:


-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
-debug
-vmargs
-Xms100m
-Xmx752m

Then I ran eclipse.exe from the command-line, hoping to get a bit more information:

$ ./eclipse.exe
Error occurred during initialization of VM
Could not reserve enough space for object heap

Now that’s a clear error message!

I need lots of memory

You may have noticed some pretty large memory numbers in the eclipse.ini.  When Eclipse starts the JVM, it will allocate a little more than 1.2Gb (752M heap + 512M permgen).

I have many large C++ and JDT projects in my workspace.  I run classic Eclipse + CDT + svn plugins.  At one point I was having some memory issues and I blindly bumped up max heap and permgen.  This worked but I may have over-compensated by making them a bit too big.

So it’s memory.  Why did it used to work?  And how to debug it?

StackOverflow and vmmap

I found some useful information from Roland Illig on StackOverflow.  The JVM allocates a contiguous block of memory for its heap.  And a DLL with an improper base address could chop up memory such that I can no longer get that nice large chunk of memory.  Roland mentioned using the Microsoft SysInternals tool vmmap.exe to debug.

First I tweaked eclipse.ini, setting the highest possible max memory setting under which Eclipse would successfully start.   It turns out that this was 660Mb in my case.

Then I fired up vmmap.exe from SysInternals.  I selected eclipse.exe, and a memory map appeared.

I looked for a large segment of (yellow) Private Data.  I found one that was 1.2Gb, as expected.

Under Options, I turned on “Show Free Regions” so I could see any free regions.

Then I looked shortly after my Private Data for any Purple “Image” entries.  These are DLLs.  I noticed that there were 3 DLLs between my large allocation and about 200Mb of memory.  The DLLs had base addresses of 5ad70000, 5b860000, and 5d090000.

ListDlls

Now I just need to map the base addresses back to the DLLs.

By running listdlls.exe from SysInternals, I got a dump of all the DLLs currently running on my system, including their base addresses.  A quick search of this file dump revealed that the errant DLLs are uxtheme.dll, netapi32.dll, and comctl32.dll.

Solution: Rebase or Tune eclipse.ini

It turns out that on XP, these DLLs were rebased too low in XP SP2. One solution is to rebase these files to a more suitable address space.  Beware: this requires great care and knowledge.  I don’t really care to mess around with these unless I have to.

A safer approach is to tune my eclipse.ini settings to a more appropriate max heap size and permgen space.  I used jdk/bin/jconsole to attach to my eclipse process.  I determine I was using about 90M of permgen space.  So I have pared back my permgen space to 128Mb in eclipse.ini and things are working great again.  I will fire up jconsole again after Eclipse has been running for a couple days to determine if these values are OK.