Use soot and Graphviz to draw a Java control flow diagram __java

Source: Internet
Author: User

After two days of hard work, don't say anything, first come to a picture:

Looks so beautiful, O (∩_∩) o haha ~



The experimental environment is Ubuntu.

1.JDK version must be 1.7 or below, JDK1.8 No, always error,

2. Download Sootclasses-2.5.0.jar Package: http://download.csdn.net/download/sheshizhang/4573588

Can be on the GitHub on the official website of the small example to try Taker: Https://github.com/Sable/soot/wiki/Introduction:-Soot-as-a-command-line-tool

3. Following the formal use of soot, first define the Soot.jar reference path:

Export Soot_path= $HOME/mooc/soot-2.4.0.jar

4. The path of the referenced class:

Export CLASS_DIR=/HOME/CPP/CP

5. Name of the custom class:

Export Class_name=test1

6. Compile Java files using Javac:

Javac $CLASS _dir/$CLASS _name.java

7. Define Soot-class Path:

Export soot_class_path= $CLASS _dir: $JAVA _home/jre/lib/rt.jar

8. Generate dot files using commands:

JAVA-CP $SOOT _path soot.tools.CFGViewer--soot-class-path $SOOT _class_path--graph=briefblockgraph $CLASS _name


The command screenshot is as follows:



9. Download the Graphviz tool below to visualize the dot file, dot file specific is what small partners can go to the official website to see.

Install the Graphviz Networking Usage command under Linux:

sudo apt-get install Graphviz

10. Verification command:

Dot-version

As shown below:




More than 10 kinds of diagram file format, there is always a suitable for you, 0 (^ dish ^) っhiahia ...

11. Use dot command:

Dot-tgif 111.dot-o 111.gif,

Here we convert the dot to a GIF, and we can see him in the automatically generated folder Sootoutput, there's a lot of excitement in the wood.

PostScript language: Recently because of the need to draw the Java control Flow diagram is not very good to meet the needs of the small partners have better tools to share out yo, you need not so hard, can be in the comments area to communicate with each other

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.