About

Jadira is the home for Sousan and Chris Pheby's open source projects. These are reusable open source Java modules that provide first class solutions using the most effective current JEE technologies.

Search
Tag Cloud
...
Login
Wednesday
Jul022008

Swing Layout Managers

Broadly speaking there are three sorts of layout managers - those that require an extensive knowledge of the finer details of swing and UI design - for example the classic GridBagLayout; those that attempt to offer a finer layout experience, but at the expense of complexity - the JGoodies libraries fall within this space; and those that make it easy for the rest of us to put together a UI and rapidly. This last category is interesting and provides a workable alternative to GUI builders such as Netbeans' Matisse.

Some time ago I discovered RiverLayout, and was able to put it to good use in small parts of a larger commercial UI. However, more recently, I discovered a much more full featured layout, similar in nature, but much more capable of producing sophisticated, yet simple and maintainable UI forms. This is MigLayout. This is an interesting toolkit, easy but powerful.

It seems that simple declarative views, loosely coupled to application logic by the mechanism of binding beans seems to be the direction in which UIs are turning. Therefore, in web UIs we have the standard of JSF, challenged by frameworks such as Wicket. In rich client UIs we have XULJavaFX, and the Lightweight UI Toolkit (for mobile devices). A number of open source declarative frameworks exist, and of course Microsoft have their XAML initiative, which makes clear that these new directions are not restricted to Java.These trends seem finally to open up the practical possibility of rapid Java GUI development.

Sunday
Jun292008

SWT 64-bit on Windows

One benefit of the release of standard 64-bit Windows builds of the Eclipse SDK is the possibility to conveniently run SWT applications on that platform.

Most SWT applications are still being packaged for a 32-bit VM. Its quite easy to modify them to run under a 64-bit JVM, here is the recipe which comes with no support or warranty whatsoever.

1. Install the application.
2. Extract swt.jar from the Eclipse.org SWT distribution. e.g. swt-3.4-win32-win32-x86_64 to the application installation directory. Typically you will be looking to overwrite an existing swt.jar instance.
3. Launch the application using a shortcut rather than any provided .exe wrapper. E.g.for the Azureus Bittorrent client, use the following shortcut: javaw.exe -classpath swt.jar;Azureus2.jar org.gudy.azureus2.ui.swt.Main

The Azureus example was originally documented on the Azureus Wiki.

Saturday
Jun282008

Eclipse Ganymede

Eclipse Ganymede SR1 was recently released. Ganymede is the simultaneous release of Eclipse 3.4 (and SR1 updates this to 3.4.1) and a bundle of Eclipse projects. InfoQ have a good article giving the low-down. Two interesting developments include the inclusion of 64-bit builds, and the use of multiple cores in compilation.

I've been using Eclipse for several years now, and always find it takes a little while to get everything configured just how you want it. In particular, a lot of the most useful plugins are not bundled with Eclipse, so you need to spend some time assembling them together.

Configuration of Eclipse

The following recipe gives describes my build of Eclipse. Any suggestions for how this can be improved are appreciated as always. The instructions are for Windows - extrapolate as required.

1. Download eclipse-SDK-3.4.1-win32-x86_64.zip for 64-bit Windows, and eclipse-SDK-3.4.1-win32.zip for 32-bit Windows.

2. Make a folder for Eclipse somewhere called 'Eclipse', and unzip the Eclipse SDK zip file to the parent folder. I typically create c:\Java\Eclipse and unzip to c:\Java

3. Create a shortcut to Eclipse, for example:

C:\Java\Eclipse\eclipse.exe -clean -vm "C:\Java\JSE6\bin" -vmargs –Xmx2048m -XX:MaxPermSize=256m

(where the ‘vm’ argument points to your appropriate Java runtime with Eclipse – this should be at least version 5.0 and should be 32-bit or 64-bit as appropriate).

NB. Best practice is to point to a JDK rather than a JRE location.

4. Next, search for new features using the Ganymede Updates (with "Show the latest version" selected).

Pick the appropriate platform features - you can safely select everything. Typical selection could be Database Development, Enabling Features, Graphical Editors and Frameworks, Java Development, Models and Model Development, Testing and Performance and Web and JEE Development.

5. After restarting again, the following update sites can be used to add AspectJ Developer Tools, SvnKit, SubClipse, M2 Eclipse, CollabNet Merge Client, QuantumDB, SpringIDE, JBoss Tools and Mylyn:

Mylyn http://download.eclipse.org/tools/mylyn/update/e3.4 (except SDK)
Mylyn Extras http://download.eclipse.org/tools/mylyn/update/extras (except SDK)
           then restart

AJDT http://download.eclipse.org/tools/ajdt/34/update (except Source Code)
SvnKit http://eclipse.svnkit.com/1.2.x/ 
           then restart

SubClipse http://subclipse.tigris.org/update_1.4.x (except JNA Library and SVNKit Library)
M2 Eclipse (Dev) http://m2eclipse.sonatype.org/update-dev/
           then restart

QuantumDB http://quantum.sourceforge.net/update-site
SpringIDE http://dist.springframework.org/release/IDE
           then restart

JBoss Tools (Beta) http://download.jboss.org/jbosstools/updates/development/ (only Hibernate Tools, JBossAS Tools, RichFaces VPE Feature, SeamTools Feature and Mozilla Libraries)
           then restart

6. Other interesting plugins you might want to consider could include:

Checkstyle http://eclipse-cs.sourceforge.net/update/
LuntClipse http://sourceforge.net/project/showfiles.php?group_id=113344&package_id=163970
LogWatcher http://graysky.sourceforge.net/
Color Editor http://www.gstaff.org/colorEditor/download.html

7. A number of plugins are best installed by hand:

Download Log4E Free / Pro from http://log4e.jayefem.de/index.php/Download (I used de.jayefem.log4e_free_1.3.2.zip) and extract it to the Eclipse/dropins directory.
Download Azzurri Clay from http://www.azzurri.jp/en/software/clay/index.jsp (I used jp.azzurri.clay.core_1.4.2.bin.dist.20080709.zip) and extract it to the Eclipse/dropins directory.
Download JavaCC plugin version 1.5.12 or greater from http://perso.wanadoo.fr/eclipse_javacc/ (I used EclipseJavaCC-1.5.13.zip) and extract it to the Eclipse/dropins directory and then restart Eclipse.
Download Jar Class Finder version 2.1.0 from http://www.alphaworks.ibm.com/tech/jarclassfinder/download and copy the Jar to the Eclipse/dropins/plugins subdirectory.
Download Tarlog Plugin 1.2.3 from http://code.google.com/p/tarlog-plugins/ (I used tarlog.eclipse.plugins_1.2.3.jar) and copy the Jar to the Eclipse/dropins/plugins subdirectory.

8. Configure eclipse.ini, for example, with the following:

-startup 
plugins\org.eclipse.equinox.launcher_1.0.101.R34x_v20080819.jar
--launcher.library
plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.0.101.R34x_v20080731
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx2048m
Saturday
Jun282008

Subversion 1.5.0 Release

Its been a busy few days for software releases. First up is Subversion 1.5.0. This is a major new release of the VCS that is rapidly becoming the most widely used system whether open source of commercial. This release contains a bundle of improvements but the most visible will be the introduction of merge tracking. Merge tracking means Subversion can record what changes have been merged into where. This makes it much less costly to maintain branches and makes it possible to review what changes are available for merging from a particular branch. This feature will be important in many organisations using Subversion, as they can now take a more pro-active branching strategy - previously, the best practice with Subversion was surely to branch as little as possible - in fact, only, when there was no other alternative.

Other interesting features are support for sparse checkouts (e.g. check out directory Y, and only two levels of subdirectory beneath), grouping of files into changelists for convenience with the Subversion commandline.

Two features will be of interest to teams distributed over large organisations and multiple geographical locations. WebDAV transparent write-through proxy builds on functionality introduced with the 'svnsync' tool in 1.4.x to allow the deployment of read only front end proxy repositories. These proxies hold a full copy of the remote repository. When such a proxy receives a write request (commits) these are forwarded directly and transparently to the master server. Subversion 1.5.0 also includes preliminary support for merging from foreign repositories. This is an interesting development which I think we are going to see more of, as the Subversion developers mull the impact and increasing adoption of distributed version management tools.

In all Subversion 1.5.0 includes more than 150 bug fixes and enhancements. The source release is available as ever from Tigris.org. Binaries are now being certified by CollabNet, which seems to represent a clearer association of the project and its major sponsor. There are new releases of TortoiseSVN and SubClipse. VisualSVN is also a new commercial tool touting Visual Studio integration, and with a free server build that provides a nice Windows management GUI and Windows domain integration.

This is an important release for Subversion, representing a evolution in its maturity which will no doubt address many of the drawbacks its contractors have used in recent years.

Saturday
Jun282008

Review: Compilers, Principles, Techniques, Tools (2nd Edition) by Aho, Lam, Sethi & Ullman

Of the literature on Compiler theory, this book is an acknowledged classic. The second edition retains the clarity and focus of the first, but is refreshed with a nod to the Java language and platform, and detailed, if still esoteric discussion of approaches for optimising compilation for multiprocessors. This book is a traditional textbook, designed to back an undergraduate course on compiler construction, and bearing in mind the advanced nature of the subject matter, this should influence your expectation of the read. In future reviews, I'll be looking at some of the books that provide a gentler, more practical introduction to the area of compilers. 

In the past, reviewers could dismiss this book - previously known as the 'Dragon' book for its distinctive cover - as being essential reading only for those involved in construction of compilers for the C programming language. Today, with the second edition, this no longer holds true. Today, with regular expressions, compiler compilers, DSLs, mini-languages, annotation processors, and AOP becoming common-place, knowledge of compiler construction provides a theoretical underpinning to all of these domains. This book lives up to its name by providing that theoretical basis, and consequently becomes an essential book to own.

Broadly speaking, the book is divided into two halves. The first parts of the book are focused on lexical and syntax analysis, and code generation using DFA parsers. The book is closely focused on C - as you would expect - but this kind of technology forms the technological basis for tools such as JavaCC, Antlr, Lex and Yacc. The newer edition makes passing reference to the JVM, but far less focus than is desirable on interpreters and more loosely (duck) typed modern languages. In my mind, this is only a minor draw back. Type inference belongs in a later stage of compilation - as a part of syntax analysis, and the principles within remain relevant.

Later parts of the book provide an interesting elaboration of issues in code and machine level optimisation, and code generation. This book provides possibly the only comprehensive treatment of this subject, but is not relevant to most readers, who will be seeking to generate compilers that either target a simple virtual machine environment such as the JVM, or that do not produce executable code at all. Furthermore, the issues of the compiler front-end - how to express the grammar, or rules, of a computer language - are only loosely coupled to this domain.

This book provides an appreciation of the transferable principles and techniques that can scale to producing parsers and interpreters for languages of an arbitrary complexity and problem domain. This is not a book on object-orientation (for that, read Meyer's Object Oriented Software Construction). Nor is it concerned with the specific use of any particular modern tool such as Antlr. There are books for these tools, consult these after reading this book. The book does not concern itself overly with the nuances of alternatives to the DFA lexer approach - this too can be found elsewhere.