MDK Development Cycle  |  MDK Wizard Configuration  |  Export a Project into a .war File

 

Import a .war File into a New Project

To activate this function select following commands from the Eclipse menu: File > Import > MDK: Import a web archive (.war) into a new project

The "import .war file" function creates a new project in Eclipse based on an existing .war file. The .war file is extracted and the files of the .war file are placed in appropriate folder of the new Eclipse project. If the .war file contains the source code of the application (WEB-INF/srclib/application_name.src.zip) the source files are placed in packages in the Eclipse project. This allows you to alter the source code of the project and create a new .war file (see, Export a Project into a .war File). All .war files supplied by the Mobile Application Development Kit (MDK) contain the source code.

Dialog window:

The dialog windows has three input fields:

  1. Archive File Name: Name of the .war file that should be imported. You can select the .war file by clicking onto the ... button and browse through the file system or you drop a .war file into the input field with the mouse.
  2. Project Name: The name of your new project in which the .war file will be imported.
  3. Project Root Folder: The folder (root) that will contain the project folder. According to the settings in the dialog window shown above a folder C:\SAPme\NewProject will be created. In case C:\SAPme\NewProject does already exist you will be notified that a project with the same "Project name" and in the same "Project root folder" already exists. In this case you must use another "Project root folder" or "Project name".

When all entries are correct the 'Finish' button is enabled. To start the import function press the 'Finish' button.

The project is generated in the Eclipse workspace and the classpath of the project is set properly. The classpath definition is made as follows:

  1. All .jar files listed in the listOfJars.txt file of the <ME_HOME> folder are added to the classpath of the project. The listOfJars.txt file is created by the Mobile Infrastructure installation process and is kept up to date with the installation of service packs.
  2. All .jar files that are located in the WEB-INF/lib folder of the imported .war file are added to the classpath of the project.
    Note: If a .jar is in the WEB-INF/lib folder and listed in the listOfJars.txt file the .jar file is added twice to the classpath of the project. This condition should never occur, since the listOfJars.txt file only contains .jar files, that are part of the Mobile Infrastructure - not of an application.

If your application needs additional .jar files, you should place them in the WEB-INF/lib folder and use the MDK project properties function to update the classpath or use the the exlib folder function of the Mobile Infrastructure (see the Mobile Infrastructure Installation Guide for details).

The Mobile Infrastructure class loader however traces all Mobile Infrastructure applications to find the class to load, regardless of the Mobile Infrastructure application name. Therefor it is important to deploy applications that have unique class names (package + class name). We recommend to change at least the package names of a newly imported project, when you plan to deploy the project as new Mobile Infrastructure application.

 

 

Directory structure .war File versus Eclipse

.war File Folder Structure

Usually the .war file has following folders:

META-INF
Contains the MANIFEST.MF file

WEB-INF
This defines the "private" (= files not seen by the world) section of your web application. The WEB-INF folder contains, besides the web.xml file, the /lib folder for the .jar files and the /classes folder for the class files of your application. In .war files provided with the MDK and in .war files you generated with the "MDK: Export a project" function (and enabled the option to include the source code) you will find also a /srclib folder which contains a .jar file with the packed source files of the application.

Depending on the application you will find other folders in the "root" and the "WEB-INF" folder.

Eclipse Project Folder Structure

After a .war file has been imported in a new project you will find following Eclipse project folder structure:

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..

 

Resource Bundles (.properties Files)

Resource Bundles can be stored in the WEB-INF/classes folder or can be packaged in the .jar file in WEB-INF/lib folder. After you imported the .war file all .properties file will be placed in the Eclipse project source folder java .

When you export your mobile application to a .war file you have the option if the .properties files should be stored in the WEB-INF/classes folder or be packed in the .jar file in the WEB-INF/lib folder.