Monday, December 28, 2009

Offline Javadoc for SWT

SWT is currently my favorite Java GUI library. It uses GTK2 as its native backend, is pretty stable and has a (rather) nice API.

It is part of the Eclipse Project. Unfortunately that means (as with all other Eclipse parts) that the documentation is not really accessible. If you need the Javadocs you have two possibilities:

1) Use the online version. There are two problem with this: a) you need an internet connection all the time and b) the Javadoc is embedded in a useless Eclipse Help frameset that eats up most of the screen making no space left for the actual content of the Javadoc:


2) Use the Eclipse help - this is basicly same as 1) but shown in an internal Eclipse browser. Plus you must install the right Eclipse components.

Sometimes you just want the Javadocs stored on you computer and browse them offline in your favorite browser. Most libraries (e.g. all Apache Foundation projects) simply offer a ZIP archive containing the documentation for offline usage. In case of SWT you have to generate them yourself. It takes only few moments if you follow this guide:

1) Download the desired version of SWT (whatever architecture you need - the Java part is same for everyone).
2) Extract the package. Besides the swt.jar and swt-debug.jar you will find the src.zip which contains the source code of the SWT library. Exctract it somewhere.
3) In the source code directory execute:
javadoc -d <your-target-dir> -sourcepath . -subpackages org.eclipse.swt -exclude org.eclipse.swt.internal

And voila - you have your offline Javadoc for SWT.

2 comments:

John Henckel said...

THANK YOU! this is exactly what I needed to know.

Shiva Kumar H R said...

Thank you. This is what I was also looking for.