Using UMLGraph to generate single dot file for multiple java classes

697 Views Asked by At

How can I ask UMLGraph to generate a single diagram for all the underlying .java classes within a package ?

I am using UMLGraph along with Graphviz to generate a .png UML diagram file. The command that I am running to geenrate a.dot file is :

java -jar C:/Program Files/Java/jdk1.7.0_80/lib/UmlGraph.jar -all -private A.java

This runs succesfully to geenrate a .dot file.

However,I wish to create a single UML diagram out of them ( They are all linked to eachother via java code). The "uml-parser-test-1" (folder/package) contains all about 5 .java files and for that I am running

C:/Users/xyz > java -jar "C:/Program Files/Java/jdk1.8.0_60/lib/UmlGraph.jar" -all -private "D:/xyz/abcd/uml-parser-test-1/"

When I run above code , I get an error : UMLGRAPH ERROR - ILLEGAL PACKAGE NAME

Where am I going wrong

                      **EDIT:: 6th Oct**

There was an issue with umlgraph.jar path and I had corrected it. Thanks for pointing that out. Now I am able to run the command you suggested without any errors. THe thing is my "Persons" package(folder) contains 4 java files(A,B,C,D.java). When I run the command, it generated .dot file on the command line and not in my file system.Moreover, it is incomplete as there is no information about classes :

Below is the trace of my command line .

 C:\Users\xyz>java -classpath "C:/Program Files/Java/jdk1.8.0_60/lib/UmlGraph.jar;C:/Program Files/Java/jdk1.8.0_20/lib/tools.jar" org.umlgraph.doclet.UmlGraph -package -output - -sourcepath "C:/Program Files/Java/jdk1.8.0_60/lib/Persons" org.umlgraph.doclet

Loading source files for package org.umlgraph.doclet...
UmlGraph: warning - No source files for package org.umlgraph.doclet
Constructing Javadoc information...
UmlGraph: warning - No source files for package org.umlgraph.doclet
UMLGraph doclet version R5_7_2-3-gee82a7 started
Building general class diagram
#!/usr/local/bin/dot
#
# Class diagram
# Generated by UMLGraph version R5_7_2-3-gee82a7 (http://www.umlgraph.org/)
#

digraph G {
        edge [fontname="arial",fontsize=10,labelfontname="arial",labelfontsize=10];
        node [fontname="arial",fontsize=10,shape=plaintext];
        nodesep=0.25;
        ranksep=0.5;
}

2 warnings

Any idea, why it is not parsing the class details?

1

There are 1 best solutions below

4
On

You must specify in the command line invocation the package name and the directory where its source code is located. The following example, when run in the UMLGraph directory, generates a diagram for the UMLGraph classes.

java -classpath "lib/UmlGraph.jar;C:\Program Files\Java\jdk1.8.0_20/lib/tools.jar" org.umlgraph.doclet.UmlGraph -package -output - -sourcepath src/main/java org.umlgraph.doclet | dot -Tpng -oumlgraph.png