MDK Development Cycle   |  MDK Wizard Configuration  |  Import a .war file into a new project  |  Export a Project into a .war File

 

Tips and Tricks using the MDK Plug-in

This describes useful tips to make the development and debug process more efficient.

Eclipse Documentation

When you are in Eclipse, select the Eclipse command "Help > Help Contents". Select "Java Development User Guide" in the contents section. There you will find a fully featured "Getting Started" section and you will learn how to set up perspectives, use the debugger and so on in the "Concepts" section.

Available Functions of the MDK Plug-in

The MDK Plug-in functions are represented by following icons:

The icons stand for the following functions are (from left to right):

We use the short description of the buttons (represented in bold characters) in the following description.

How can I start ?

Import a .war file
To start a new Mobile Infrastructure project you can select one of the many .war files, supplied by the MDK. The .war files represent the MDK examples and have well documented Java code and JSP examples. Select the example the suits you best and import it with the "Import a .war file" function and you have a new project on your Eclipse workspace.

Develop your application
Now you can make changes to the project. Change the existing servlet, add classes, change the JSP or add JSP and so on.

Export a project to a .war file
When you want to execute your application you "Export a project to a .war file". This function allows you to instantly deploy your application locally and run it.

A Mobile Infrastructure application has to be declared with the web console to the web application server. See the administrator guide for details.

Usually you application is started in the web browser directly with the URL that is computed by the name of the .war file you specify and the URL pattern. Some applications however (like applications using the Persistence layer) have to be started from the Mobile Infrastructure Homepage. You can set this option in the dialog window of the export function. See, "Export a project to a .war file" for more details.

 

How can I debug the Java code?

Once your application successfully deployed you can debug your application in two ways.

When you do not want to deploy your application all over again, which is done with the "Automatic" option, you can start your application manually. The MDK plug-in adds a launch configuration with the name of the project when the "Export a project to a .war file" function is performed. Select the Eclipse commands Run > Debug ... and select the "Launch Configuration" of your application. All MI applications can be found in the launch configuration group "MI Application". Press the "Debug" button and your application is started. You do not have to stop the Mobile Infrastructure before you "Run" your application. The Launch configuration uses a class provided by the MDK, that takes care of that.
To bring your application to life you have to activate a browser window, go to the MI Homepage and start your application. The application will stop whenever it hits a breakpoint.
You can customize Eclipse so that the "Run" and "Debug" commands are in the Eclipse toolbar . By clicking onto the symbols, the project launch last is launched again. By clicking onto the drop down symbols you get a list of recently launched projects.

The "Manual" method allows you to change Java code "on the fly", without deployment.

For basic information how to debug with Eclipse and a work around for JSP debugging, see Debugging with Eclipse.

When you have a large application with many methods, the export function can take a while, since it compiles and puts all class files into a .war/.jar file. While you are testing and debugging your application, it is faster to start the application manually ("Run ..." or "Debug ..."). In this case, you start the mobile application directly out of Eclipse using the class files from the Eclipse project. So you save a lot of time by avoiding the packaging and deploying of the application.
Use the export function when you are finished with testing and you need a final .war file.

 

How can I debug JSP ?

Export your project with "Export a project to a .war file" function. Enable the "Add JSP as compiled classes" option and select "Keep generated Java files in project after .war file has been generated" in the export dialog window. You do not have to enable "Run the mobile application".

Now you have the Java files of the JSP compilation in the $JSP source folder of your Eclipse project. Now you can start your project in Debug mode

We strongly recommend to use the Java files in the $JSP source folder only temporarily and for debugging purposes only. When you have found the bug in your JSP, make the changes in the JSP and than export the project again with the "Add JSP as compiled classes" option enabled. Never change the Java files in the $JSP source folder.
Because of the temporarily use of the Java files we do not organize the imports and format the source code of the Java files in the $JSP folder. This leads to some warning icon in the $JSP folder indicating unused import statements. The warning icons do not cause any harm and should remind you, that these files are only temporarily.

 

How about JSP ?

When you debug your application and you have to change your JSP, you can do that in Eclipse. When the JSP file is changed and saved, press the "Export JSP" button. This will automatically copy all JSP of the selected project to the corresponding web application without new deployment. The Mobile Infrastructure does not have to be restarted. So your application keeps its state which is very helpful when you are in debug mode. Tomcat compiles the JSP when it is called the first time.

When you have finished your development you can use the "Export a project to a .war file" function to create a final .war file.


I have installed an Update of the Mobile Infrastructure and want to Update the Classpath of an Existing Project.

Select the MI Project Property button and click on the FINISH button. The classpath is updated acording to the listofJars.txt file in your Mobile Infrastructure home folder. See the "Project Properties" documentation for more details.

 

I created a Mobile Application in Eclipse without the Plug-in and want to use the Plug-in now.

You have to create a new MI Project and import the your sources into the new project with the standard Eclipse commands.

Your project must have following settings:

JSP Project:

Java Source folder java
Web application folder (for images, JSP and so on) app-root
Output folder (folder in which Eclipse stores the compiled .class files) app-root/WEB-INF/classes

 

AWT Project:

Java Source folder java
Other folders (for images) no specific folder required
Output folder (folder in which Eclipse stores the compiled .class files) classes

 

I want to create a new Mobile Application in Eclipse from Scratch.

Create a new Eclipse project. Create a new Source folder "java". Now you import the Java sources. Now follow the steps described in "I created a Mobile Application in Eclipse without the Plug-in and want to use the Plug-in now." above.