Home » IDE
Category Archives: IDE
I use Eclipse (Kepler) for my Java development. As you know, Eclipse is an Open Source IDE available for many languages/platforms. It’s great with many options even my PowerBuilder IDE doesn’t provide.
Where Eclipse is lacking, it allows for Plugins to be added. This is really great. Being Open Source, there are so many options available out there.
I wanted to generate UML for my Java classes and I tried various plugin in Eclipse. I did not want to hand code them, but instead just import Java classes and let the tool generate UML. They did not work as I wanted. Closest one I got was ObjectAid. This actually lets me create a class diagram and drag and drop Java classes. It generates decent class diagram. The only problem being it seems to only list Composition relationships and not inheritance.
Then I stumbled on YWorks UML Doclet. Essentially, you use this as a custom doclet in the Javadoc options and it generates Javadoc with embedded UML diagrams!!
Getting UML Doclet to work is a bit tricky. You have to mention several options, but I didn’t find one place that mentions all these options yet. After some trial and error and enough Googling, I found the following setup works for me:
In Eclipse, Click on Project -> Generate Javadoc. This will open the Javadoc Dialog (You can also use File -> Export -> Javadoc to get here).
If multiple projects open, choose the project you want Javadoc generated for. This is no different from generating the regular Javadoc. Now, if you want UML Doclet to do its job, choose Custom Doclet and enter the following details:
Doclet Name: ydoc.doclets.YStandard
Doclet Class Path: <YDoclet Dir>\lib\ydoc.jar
Where <YDoclet Dir> is the absolute path where installed/copied the YWorks Doclet to. Type the full path there. Since I am on Windows, I use backslashes and double up all backslashes for Java.
For e.g., I’ve installed my Doclet at C:\util\yworks-uml-doclet-3.0_02-jdk1.5\, so I replaced <YDoclet Dir> with this.
Where it says VM Options, enter the below string:
-license <YDoclet Dir>\resources\ydoc.license -resourcepath <YDoclet Dir>\resources\ -docletpath <YDoclet Dir>\resources;<YDoclet Dir>\lib\class2svg.jar -umlautogen -d c:\temp\javadoc
So for example, in my case, I had to set the VM options to,
-license C:\\util\\yworks-uml-doclet-3.0_02-jdk1.5\\resources\\ydoc.license -resourcepath C:\\util\\yworks-uml-doclet-3.0_02-jdk1.5\\resources\\ -docletpath C:\\util\\yworks-uml-doclet-3.0_02-jdk1.5\\resources;C:\\util\\yworks-uml-doclet-3.0_02-jdk1.5\\lib\\class2svg.jar -umlautogen -d c:\\temp\\javadoc
Notice -d option to set the destination. I added this, so I could find my generated Javadoc files!! Otherwise, I couldn’t find the files after JavaDoc was generated (no it did not put it in Project folder, like regular Javadoc would do). -umlautogen probably adds the UML diagrams to the Javadoc.
(Also, note that the VM options text box doesn’t scoll in the version of Eclipse I have. If so, make the window itself wider. Or make the options string in notepad and paste it into the above box).
Choose JRE Source compatibility.
These settings will be retained in Javadoc generation, until you change it. You also have the option of saving these saving these settings in an Ant script, so you can run it outside of Eclipse as well.
Click Finish, voila!! You will see your Javadoc with embedded UML like shown below.
I saw a question on Stackoverflow that linked back to this post. Essentially, the post authors were getting below error message:
javadoc: error - In doclet class ydoc.doclets.YStandard, method start has thrown an exception java.lang.reflect.InvocationTargetException java.lang.NoSuchMethodError: com.sun.tools.doclets.internal.toolkit.taglets.TagletManager. getConstructorCustomTags()[Lcom/sun/tools/doclets/internal/toolkit/taglets/Taglet; ....
I did some testing on this and found out that they might be using Java JDK 1.8. My project uses Java 1.5, that’s why I downloaded the ydoc for Java 1.5 and set it to 1.5 compatibility above. But, just for this test, I changed the Javadoc Command on the first window to C:\Java\jre1,8.0_65\bin\Javadoc.exe. This caused the above error.
I tried mixing Javadoc.exe from Java 1.6 and Java 1.7 directories and they did fine. So, it seems to be a Javadoc version issue. Incidentally, yworks mentions only JDK 1.5, 1.6, 1.7 as supported version for the ydoc.