MDK Development Cycle | MDK Wizard Configuration | Import a .war file into a new project | New MI project
To activate this function select following commands from the Eclipse menu: File > Export > MDK: Export project into web archive (.war)
This function creates a .war file of your Eclipse project. First you will be asked which project you want to export. Only "MDK projects" are displayed. In case your project does not show up, you have to create a "New MI project" and import the sources with the standard Eclipse commands. After you select a project the export dialog window, depending on your application type (JSP or AWT) is displayed.
![]() |
The archive must have the name as the application. The application name is defined in 'getApplicationName' method of your implementation of the AbstractMEHttpServlet or AwtApplication. The application name must not exceed 30 characters. In case you select a archive file name that has more than 30 characters, the dialog window displays a message: |
Case 1. AWT application:
Case 2. JSP Application with disabled JSP compilation option:
Case 3. JSP Application with enabled JSP compilation option:
![]() |
When you export one project under different .war file names you create different web applications. The Mobile Infrastructure class loader however traces all web applications to find start a class, regardless of the web application name. Therefore it is important to deploy applications that have unique class names (package + class name). |
![]() |
When a .war file has to be deployed on a device that has only a Java Runtime (JRE) installed, you have to create the .war file with compiled JSP. JSP compilation by the Tomcat servlet engine requires the Java Development Kit (JDK). |
![]() |
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. Adjustments in the web.xml file: |
![]() |
All mobile applications need to be deployed at least once via the MI Web Console before being started via this feature. Only when deployed via the MI Web Console, a mobile application is properly registered with the MI framework and can then use framework services. Please read the instructions in chapter 'Software Logistics -> Deployment during Development' in the MDK documentation carefully. If it is a new mobile application you are deploying, the Run the mobile application option is disabled. A text line under the check box displays a message that the application has to be deployed via the MI Web Console. The MI Web Console is started by the export function when you choose Finish (the MI Client Installation has to be configured correctly, for example, port number and server name, to allow the export function to start the Web Console). If the MI runtime does not match the archive, for example. you are trying to export a .war file but the MI runtime is configured for AWT, the check box to run the mobile application is disabled. |
web.xml for EXAMPLE.war <web-app> <servlet-mapping> <servlet-name>Example1</servlet-name> <url-pattern>/start</url-pattern> </servlet-mapping> <servlet> <servlet-name>Example1</servlet-name> <servlet-class>example1Servlet</servlet-class> </servlet> </web-app> This entries define, that the class example1Servlet is called when the mobile application is started with the URL: http://localhost:4444/EXAMPLE1/start |
In order to be compatible with PDAs your mobile application should be built with Java Version 1.1.8. You can select the Java version which is used for building with the Eclipse commands:
Window > Preferences > Java > Installed JREs
The export function of the MDK Plug-in also creates a "Launch Configuration" in Eclipse under the launch configuration group "MI Application". You have access to the "Launch Configuration" by using the Eclipse commands Run > Run ... or Run > Debug.... The "Launch Configuration" has the name if the project and give you the opportunity to start your application manually. See, Tips and Tricks for more details.
Eclipse project folder structure of a mobile application:
java
A package folder that will contain the source code of the application. The source
code is extracted from the .war file folder WEB-INF/srclib/application_name.src.zip.
app-root
A folder that contains the "root" folder of the .war file. In the
"app-root" folder you will find the folders "META-INF",
"WEB-INF" etc..
When you export a project into a .war file it has following folders:
Eclipse folder |
.war file folder |
/java /... | All .java files are packaged and saved as WEB-INF/srclib/WARFileName.src.zip. Resource bundles (.properties) are packaged in the .jar file in the WEB-INF/lib folder of the .war file. |
/app-root /... | All folders under app-root are placed in the root folder of the .war file. For example, Eclipse project folder /app-root/WEB-INF becomes WEB-INF in the .war file. |
When you create a .war file and start Tomcat the files in the .war file are deployed. JSP are "precompiled" by Tomcat into .java files when called the first time. The Java compiler is started and creates the final class file of the JSP servlet and your application is displayed in your web browser. The "compilation" process takes place in the work folder of Tomcat which is located in <ME_HOME>/work.
When you deploy the application frequently during testing time it can happen, that the latest JSP you deployed is not "precompiled" by Tomcat and an older "precompiled" version is used - so your changes would not be visible. In this case delete all application-context-specific folders in folder <ME_HOME>/work and start again.
It can happen, that the you get an exception during the export function, that indicates that resource cannot be deleted. This error occurs when Eclipse cannot clean the output folder. Eclipse cleans the output folder (usually folder WEB-INF/classes) before it recompiles the project. For an unknown reason so far, the .class files are locked by the Java VM and Eclipse cannot delete the files. Right now the only thing we can recommend is:
Close the project and open the project again. To do that, click on the project with the right mouse button and select "Close Project" from the context menu. To open the project, click on the project with the right mouse key again and select "Open Project" from the context menu. You have to rebuild the Project (Eclipse command: Project > Rebuild Project) to get rid of the error sign in front of the project.
If there are still problems you have to restart Eclipse (Closing Eclipse and
start it again).