Set Java

Astah supports modeling in Java, C++, and C#. If you are modeling in Java, set so in Astah first.

  1. Select a root package on a tree and check [Java] in the bottom pane.
    Set Java to Astah

  2. Then Java options in [Language] tab become available for Classes, Attributes, and Operations.
    Java options for Classes, Attributes, Operations

Set Java as a default programming language

TIPS – Set Java to a project by default

You can set Java as your programming language to Astah by default from [Tools] – [System Properties ] – [Project].

section divider

Import Java Source Code

You can import Java source code and generate Class diagrams with the models.

  1. Go to [Tools] – [Java] – [Import Java].
    Import Java

  2. Choose .java files you want to import and click [OK]. Make sure you select the right encoding.
    Select files to import .java files

  3. Choose attributes that you want to import as associations.
    Check attributes to import as association

  4. Imported models are added on the tree.
    Imported models on the tree
section divider

Auto-generate Class Diagram

You can auto-create a Class diagram with imported models.

  1. Right-click on a package or class and choose [Auto Create Class Diagram].

  2. Generate diagram is opened in the Diagram Editor.
    Generated UML Class Diagram

TIPS – Use Auto-layout

After generating a diagram, you can auto-layout from [Alignment] menu.

section divider

Use Reverse Plug-in

Astah’s Easy Code Reverse Plug-in is the easiest way to reverse source code from Github, Bitbucket, and Gooogle Project Hosting into a UML class diagram just by drag-and-dropping the URL a repository or the .java source code files directly on to Astah!

  1. Install Astah’s Easy Code Reverse Plug-in
  2. Directly drag the link of the .java file from online repository.
    Easy Code Reverse

  3. The imported model would appear on the diagram.
    Reversed Class
section divider

Generate Java source code

“Export Java” is used to generate Java Skeleton Code from selected Diagram Elements. The Definitions of Classes and Operations are exported as Documentation Comments.

  1. Go to [Tools] – [Java] – [Export Java] from Main Menu.
    Export Java

  2. Select models you want to export to source code.
    Java Export

  3. .java files would be generated. If a .java file with the same name already exists, it will be overwritten.

Sample source code

Sample UML Class Diagram
Exported Java source code