Compiling everything

 

In this subsection we compile all the Java files that were generated in the previous sections. It is possible to use an external Java IDE to do it, but the CDE provides a simple interface to JDK for this purpose. 

The first step is to tell CDE where it can find the necessary information to compile the generated files. This is done in the project options dialog. Remember that there are two ways to open it:

  1. Select Project Options... from the Project menu.

  2. Right-click on the project root node and choose Project Options... from the pop-up menu.

The dialog that appears has three tabs. This time, only the Files/Directories tab is relevant. The first text field is to introduce the directory where JDK is installed. You only need to provide this information if the Java compiler is not in the command path. The second field is mandatory: you have to introduce the path of the runtime classes, namely file cderuntime.jar in the CDE installation directory.  In the third field you must provide all directories containing Java files needed by the components and contracts in the project. 

In our example, the Account class needs the AccountException class and the AccountExceptionTypes interface and the contracts need the same interface. Both are part of the Bank package which is in the source directory. Therefore, click on the Add button and select the demos/tour/src directory. Press OK to close the project options dialog.

Now we can compile the files.

  1. Make sure the Generated Files node of the Account component is expanded.

  2. Right-click on the File:Account.java  node and select Java Compiler.

A message appears stating that the file has been compiled. Using Windows Explorer you can check that the project directory (i.e., demos/tour) has a new subdirectory classes that contains the compiled files, mirroring the package structure of the application. In this case, the compiled files are in the Bank subdirectory.

We can now proceed in the same way, compiling file by file in all the Generated Files subtrees of all components and contracts. A faster way is to right-click on a component or contract node and select Java Compiler to compile all Java files generated for that component or contract. An even faster way is to select the same command in the pop-up menu for the project root node. This will walk through the whole project tree and compile all generated Java files. All error messages issued by the Java compiler will be shown on the message pane. In this case, as we are sure the files contain no errors, it is a good option, otherwise it might be better to compile files one by one, or one component/contract by one, to avoid having the message pane with too many errors.

Errors are reported on the generated Java files, and therefore you must try to understand from the error location and description where the problem is in your components and contracts. Every file generated by CDE starts with the name of the component or contract from which it was generated. Hence, the name of the Java file containing the error lets you easily know which component or contract you will have to change. Next, look at the error message and see the Java code that the compiler reports to have a problem. Try to find a line in the component or contract which is similar to the line displayed by the Java compiler. If you cannot find any similar code in the original component or contract, then it may be a bug in the code generated by the CDE. Please report it to us. If the error is of the kind "class/package not found", then you probably forgot to include in the source path all the necessary directories. In that case go back to the project options as explained above.

Having successfully compiled all files, it is a good time to save the project by selecting Save Project from the File menu. Alternatively, you may right-click on the right pane (i.e., the one with the project tree) and select Save Project from the pop-up menu. Make sure you don't right-click on any node, because that would make the context menu for that node appear.

Now let us move on to the animation of the generated and compiled Java files.

Top    CDE Documentation Home    Next