Tuesday, March 27, 2012

NetBeans 7.0 and 7.1 UML plugin

If you are using NetBeans 7.0 or 7.1, you probably can't find your UML plugin any more in the default repository.

From what I can read on the net, the team is working on the plugin rewriting it, and this will take a while.


Semi-broken solution

There is another way to install it, but beware, the plugin will be semi-broken, so jump down to another solution if you like to generate a pretty UML diagram from your code:
  1. by the menu navigate to Tools -> Plugins;
  2. select the "Settings" tab;
  3. click the "Add" button;
  4. as URL copy the following into the textbox:
    http://dlc.sun.com.edgesuite.net/netbeans/updates/6.9/uc/m1/dev/catalog.xml
Now on the tab "Available Plugins" there should be UML in category UML.

The problems are:
  • "reverse engineering" command seem to work but you can't open the files;
  • you can write a class diagram and work on it, but when you open your project next time you will unable to open the diagram again.
So all you can do is work on a temporary diagram, if you need only it.


Another solution

You can use yWorks UML Doclet community edition.
This solution will only let you generate a pretty UML diagram from your code.

  1. Download the library from here;
  2. right click on your java project in project explorer within NetBeans;
  3. click on "Properties";
  4. select  Build => Documenting;
  5. on "Additional Javadoc Options" textbox paste the following (beware, I'm under windows):
    -docletpath "<yworks-uml-doclet-path>\lib\ydoc.jar" -resourcepath "<yworks-uml-doclet-path>\resources" -doclet ydoc.doclets.YStandard -umlautogen

    Where <yworks-uml-doclet-path> is the path of the yworks-uml-doclet folder.
    In my case <yid> is:
    E:\Users\retek\dev\lib\java\yworks-uml-doclet\yworks-uml-doclet-3.0_01-jdk1.5
  6. click "OK";
  7. right click on your java project in project explorer within NetBeans;
  8. click Generate Javadoc;
Now, within your Javadoc you will have a very nice UML driagram for your classes.

Thanks to Matthew W. Johnson for this solution.

65 comments:

  1. I got and error
    javadoc: error - Cannot find doclet class ydoc.doclets.YStandard

    ReplyDelete
  2. Its giving me an error
    javadoc: error - Illegal package name: "\lib\ydoc.jar"

    My Additional Javadoc Option is
    \lib\ydoc.jar

    ReplyDelete
  3. Hello Isu San!
    Have you tried to use a full path? (like c:\yourDirectories\lib\ydoc.jar)

    Let me know how it goes :)

    ReplyDelete
  4. Still having the same error.. :(

    ReplyDelete
  5. Can you post your full "Additional Javadoc Options" please?

    ReplyDelete
  6. Thank youuuuuuuuuuuuuuuuuuuuuuuuuuu

    ReplyDelete
  7. Thank you very muuuuuuuuuuuuuuuuuuuucccccccchhhhhhhhhhhhh

    ReplyDelete
  8. Replies
    1. Thanks Michele Lepri!!!

      But when i generate javadoc, i got this error/warning:

      javadoc: warning - Could not locate class file for package.class.java

      Please ensure that the directory, JAR archiv, or ZIP archive, which contains the compiled, unobfuscated class XML.XML, is included in the docletpath option.

      How can i fix it??It doesn't allow to view the link between some packages in overview and in so many other views;

      Thanks for the answers.

      Delete
    2. Hi Insidemyhead!
      Can you please post your "Additional Javadoc Options" text?
      thanks
      michele

      Delete
    3. so it is:

      -docletpath "/home/insidemyhead/Documents/Software/yworks-uml-doclet-3.0_02-jdk1.5/lib/ydoc.jar" -resourcepath "/home/insidemyhead/Documents/Software/yworks-uml-doclet-3.0_02-jdk1.5/resources" -doclet ydoc.doclets.YStandard -umlautogen

      Thanks!!

      Delete
    4. between all words there is only one space.

      Delete
    5. Well, the command seems to be correct.
      What jump to my mind is to ensure that your file and directory exist.

      Try to do a
      ls /home/insidemyhead/Documents/Software/yworks-uml-doclet-3.0_02-jdk1.5/lib/ydoc.jar

      and a

      ls /home/insidemyhead/Documents/Software/yworks-uml-doclet-3.0_02-jdk1.5/resources

      to see if they are correct.

      Let me know how it will go!
      =)

      Delete
    6. the output is:
      /home/insidemyhead/Documents/Software/yworks-uml-doclet-3.0_02-jdk1.5/lib/ydoc.jar (for the first command)

      styles taglet_definitions.xml taglet_templates.xml ydoc.license
      taglet_definitions.dtd taglet_templates.dtd ydoc.cfg
      (for the second one)

      Maybe i have to add some rules in additional Options about libraries that i used in project development?

      Delete
    7. Maybe you have to do, but first..

      Are you using OSX or some GNU/Linux distribution?

      Sorry for this "simple" question, but have you installed JDK 1.5.0 or JDK 1.6.0 ?

      Delete
    8. Another tip to try: remove all quotation marks because you don't have any spaces in your paths, so you don't need them.

      Delete
    9. Also in answer to the error where it says about the classes not being there, you have to include the path to your compiled jar file in the -docletpath switch argument. So after adding the path to the doclet just include a path to your compiled jar as it shows on the ydocs documentation site.


      Important:
      If you want to use the yDoc UML generation, docletpathlist must also contain the path to your compiled, unobfuscated Java class files (*.class), for which you want to generate the API documentation, and to all libraries needed to compile your Java source files.

      eg.
      -docletpath <YID>/lib/ydoc.jar;<YID>/resources;<some path>/myapp.jar

      Delete
  9. Hello, I have the same problem that Isu San:
    javadoc: error - Cannot find doclet class ydoc.doclets.YStandard

    this is my Additional Javadoc Option:
    -docletpath "/Users/eoportus/Downloads/yworks-uml-doclet-3.0_02-jdk1.5\lib\ydoc.jar" -resourcepath "/Users/eoportus/Downloads/yworks-uml-doclet-3.0_02-jdk1.5\resources" -doclet ydoc.doclets.YStandard -umlautogen

    I'm running JDK 1.6 in MacOSX 10.7.4.

    Thanks,

    ReplyDelete
    Replies
    1. Hello eoportus,
      can you try use this command (I have simply changed "\" with "/" when needed and removed unneeded quotation marks).
      -docletpath /Users/eoportus/Downloads/yworks-uml-doclet-3.0_02-jdk1.5/lib/ydoc.jar -resourcepath /Users/eoportus/Downloads/yworks-uml-doclet-3.0_02-jdk1.5/resources/ -doclet ydoc.doclets.YStandard -umlautogen

      Let me know how it will go!

      Delete
  10. Thank you very much

    ReplyDelete
  11. wow!!!!!!!!!!
    Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    ReplyDelete
  12. How can I use it within Maven based project? It doesnt have that build => Documenting settings there.. please help!

    ReplyDelete
  13. Hi Saifullah Ansari,
    I never used Maven project management and I don't know how to help you: have you try to ask to Maven support mailing list?
    Regards

    ReplyDelete
  14. thank youu sooo much!!

    ReplyDelete
  15. Hi im trying to use yWorks UML Doclet but it doesnt generate any uml diagram. Im missing something? Thanks

    ReplyDelete
    Replies
    1. Hello, I'm assuming you have followed the procedure.
      Are you getting some sort of error message?
      Can you please give me more details?

      Let me know =)

      Delete
    2. Thanks for your reply, nope im not getting any errors Im able to generate the javadoc with the html info but theres no diagram at all.
      Thanks

      Delete
    3. You are welcome,
      are you sure you have configured it fine?
      Without any other clues on your problem is really hard to try to help you from here, sorry.

      Delete
  16. Thank you for this post. It works great.

    ReplyDelete
  17. and you should add the following css to the file /dist/javadoc/stylesheet.css

    .UmlTable{
    width:0% !important;
    border-collapse: collapse;
    border:0px;
    }

    .UmlTableCell{
    padding:0px !important;
    }

    Then it looks great!

    ReplyDelete
  18. -docletpath "C:\Users\Chip\yworks-uml-doclet-3.0_01-jdk1.5\lib\ydoc.jar" -doclet ydoc.dockets.YStandard -umlautogen -resourcepath "C:\Users\Chip\yworks-uml-doclet-3.0_01-jdk1.5\resources"

    doesnt work for me :(
    Generating Javadoc
    Javadoc execution
    javadoc: error - Cannot find doclet class ydoc.dockets.YStandard
    1 error

    ReplyDelete
    Replies
    1. try this: -docletpath C:/Users/Chip/yworks-uml-doclet-3.0_01-jdk1.5/lib/ydoc.jar -resourcepath C:/Users/Chip/yworks-uml-doclet-3.0_01-jdk1.5/resources -doclet ydoc.doclets.YStandard -umlautogen

      Delete
  19. 1 error
    C:\Users\nys\Documents\NetBeansProjects\SistemPenjualan\nbproject\build-impl.xml:1195: Javadoc returned 1
    BUILD FAILED (total time: 0 seconds)

    can you help me ?

    ReplyDelete
    Replies
    1. Hi =)
      can you get more details about this error?

      Delete
  20. It works like a charm :), thank you. If you get a BUILD FAILED, just put it on C: or D: in a folder, like C:\yourfilder. It will work.

    ReplyDelete
  21. Thank you!!! A curiosity...when it generates some images, it splits them in two. Does exist any configuration to avoid this issue? I've read a bit of user guide, but i could not find any solution.

    ReplyDelete
    Replies
    1. Sorry I don't know any solution for this.

      Delete
    2. If you go into this directory <your path to extracted doclet>\yworks-uml-doclet-3.0_02-jdk1.5\yworks-uml-doclet-3.0_02-jdk1.5\resources and edit ydoc.cfg using notepad or whatever search for the tiling group tag and set it to false... It should look something like this:

      <group name="tiling">
      <property name="enabled" value="false"/>
      <property name="width" value="600"/>
      <property name="height" value="600"/>
      </group>

      this stops the images from being split.

      Delete
    3. PS great post Michele thanks :)

      Delete
  22. Warning: Leaving out empty argument '-windowtitle'
    Generating Javadoc
    Javadoc execution
    1 error
    java.lang.NoClassDefFoundError: com/sun/javadoc/DocErrorReporter
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
    at java.lang.Class.getMethod0(Class.java:2685)
    at java.lang.Class.getMethod(Class.java:1620)
    at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:257)
    at com.sun.tools.javadoc.DocletInvoker.optionLength(DocletInvoker.java:184)
    at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:347)
    at com.sun.tools.javadoc.Start.begin(Start.java:167)
    at com.sun.tools.javadoc.Main.execute(Main.java:59)
    at com.sun.tools.javadoc.Main.main(Main.java:49)
    Caused by: java.lang.ClassNotFoundException: com.sun.javadoc.DocErrorReporter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 10 more
    javadoc: error - fatal error
    C:\Users\Roger\Desktop\ProjectX\nbproject\build-impl.xml:1388: Javadoc returned 1
    BUILD FAILED (total time: 1 second)

    ReplyDelete
    Replies
    1. Maybe you have a wrong setup: try to review it or post some more details please.

      Delete
  23. Im getting this error
    Warning: Leaving out empty argument '-windowtitle'
    C:\Users\Aled\Desktop\NetBeans java\Lab5\nbproject\build-impl.xml:1195: No source files and no packages have been specified.
    BUILD FAILED (total time: 0 seconds)
    Any help out there?
    Tahnks.

    ReplyDelete
    Replies
    1. This is a generic error.. try to review your set up: can't help you mutch, sorry

      Delete
  24. i had 15 mins to make a UML diagram as i had to meet a deadline . Think link did it . Thanks so much :-) Live Strong !

    ReplyDelete
  25. Thank you! Very helpful for experts. I installed this in netbeans, and i'm from switzerland and i'm 48. Im a teacher in St.gallen.
    St.Gallen is a very nice place to be. I like it so much.You are the best! Peace and Love for you Guys. Best Regards your Jenny.

    ReplyDelete
  26. i dont getting class diagram of project

    ReplyDelete
  27. I had the same problem as Isu San but I realised, stupidly, my yworks-uml-doclet-3.0_02-jdk1.5 was still compressed which is why I was getting the error 'javadoc: error - Cannot find doclet class ydoc.dockets.YStandard'. After I sorted this all out and changed the , it worked perfectly. Thank you!

    ReplyDelete
    Replies
    1. Very good =)
      You are welcome and thanks to share your experience!

      Delete
  28. when I run the Javadoc gerador I get this error line

    C:\Users\AMOR ETERNO\Desktop\RRHH\nbproject\build-impl.xml:850: Javadoc returned 1
    GENERACIÓN INCORRECTA (total time: 1 second)


    init:
    Warning: Leaving out empty argument '-windowtitle'
    Generating Javadoc
    Javadoc execution
    Loading source file C:/Users/AMOR ETERNO/Desktop/RRHH/src/accion/DeptAction.java...
    Loading source file C:/Users/AMOR ETERNO/Desktop/RRHH/src/accion/EmpAction.java...
    Loading source file C:/Users/AMOR ETERNO/Desktop/RRHH/src/accion/ProdAction.java...
    Loading source file C:/Users/AMOR ETERNO/Desktop/RRHH/src/accion/UsAction.java...
    Loading source file C:/Users/AMOR ETERNO/Desktop/RRHH/src/accion/VentaAction.java...
    Loading source file C:/Users/AMOR ETERNO/Desktop/RRHH/src/coleccion/ColDept.java...
    warning: [options] bootstrap class path not set in conjunction with -source 1.5
    javadoc: error - Illegal package name: "C:\yourfilder\yworks-uml-doclet-3.0_02-jdk1.5"

    I can help,,,, thanks

    ReplyDelete
    Replies
    1. Hello Ronnal,
      I think you miss the full path of "-docletpath" argument.
      The path should be something like "C:\yourfilder\yworks-uml-doclet-3.0_02-jdk1.5\lib\ydoc.jar".
      Let me know

      Delete