Astah User's Guide

Import/Export Java Source Code


Import Java Source Code

“Import Java” is used to import Classes and their parent Packages from .java files into the current Project. If the target .java file does not specify a Package, the Class (Model Element) is generated under a Package called “no-title”.

  1. To import .java files, select [Tool]-[Java]-[Import Java] to open the [Select Java File] Dialog.
  2. Specify the charset to use upon on importing .java files.
    select_javafile
  3. Click [Start] button to start import.
    Import Java
  4. Check Attributes you want to reverse as Associations.
    Java Import
  5. Now Classes and paremt packages will be imported in the project.
    Java Import
  6. Importing Java Source Code does not automatically create Class diagrams. In order to auto-create a class diagram with imported classes, select [Auto-create Class Diagram] from pop-up menu in the structure tree.
    autocreate classdiagram

Export 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. Select [Tool]-[Java]-[Export Java] in the Main Menu to open the “Select” Dialog.
  2. Select the target Model, from which .java files are to be generated, in the “Select Diagram Element” Dialog.
    Specify the charset to use upon on exporting .java files.
    Export Java Source Code
  3. Click [OK] to export the .java files.

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

Sample of generated Java Source Code

Engine.java in the diagram below:


Sample Class Diagram
package Class;
public class Engine {
	   private Motor motor;
		 public void forward() {
		 }
		 public void backward() {
		 }
		 public void brake() {
		 }
}