Generating Java code
Introduction to Java code generation
A .java
type file is generated for each class of the model on which the "Generate" command is run.
However,
code can also be generated from a package.
A .java file is then generated for each of the package's classes.
No code is
generated for elements annotated by the {JavaExtern}
tagged value
(for example, this is the case for an element produced by the Objecteering Java
Developer reverse) or the
{nocode} tagged value. This also
applies to classes annotated using the {JavaNonPublic}
tagged value or to inner classes. The code of these classes is to be
incorporated in the .java of the class which contains them.
Launching Java code generation
To generate
code, carry out the steps shown in Figure 15.

Figure 15. Running Java code generation
Steps:
1. Right-click on the "FirstSteps" package in the explorer to open the context menu.
2. Run the "Java Developer/Generate" command..
You can monitor the progress of the code generation in the console (as shown in Figure 16).

Figure 16. Monitoring the progress of code generation in the console
Note: You can go up and down in the console by using the scroll bars.
Visualizing the generated Java code
After code generation, you can visualize the generated Java code.
To visualize
generated Java code, carry out the steps shown in Figure 17.

Figure 17.
Running the "Visualize" command
Steps:
1. Right-click on the "BankAccount" class in the explorer to open the context menu.
2. Run the "Java Developer/Visualize the code" command.
This command
opens a window containing the generated Java code (shown in Figure 18). It is not possible to modify the code directly in this window.
However, it
is possible to modify certain elements directly from the model. The elements you can modify are highlighted in blue. Double-click
on the blue text to open the dialog box for the model element, in which you can
make your modifications.

Figure 18. Window displaying the Java code of the "BankAccount" class
Steps:
1. Double-click on the blue "Bank" text. The dialog box of the "Bank" package will open.
2. Make the necessary modifications.
3. Confirm by clicking on the "OK" button.
Editing the generated code
It is also possible to edit the generated Java code for a class using an external editor defined using the "Command for invoking external editor" parameter.
Zones represented between markers can be modified. Modifications are directly incorporated into the model when the editor is closed.
For this, select a class and click on the "Edit" button in the Java tab, or else run the "Edit" command in the context menu.
Updating the model
The Java code associated with a model's class can also be modified outside Objecteering. The modifications made outside Objecteering can then be incorporated into the model, using the "Update" command.
For this,
simply carry out the following operations:
1. Modify the "CheckingAccount.java" class outside Objecteering.
2. Run the "Java Developer/Update" command from the "CheckingAccount" class.
3. Make sure the corresponding text zone has been modified in Objecteering.
The "Update" command can be used with both the round trip and model driven modes, and updates the model from the code contained between markers. Any modifications made outside the marked zones will be ignored. In this case, the "New Reverse" command should be used after compiling the model.