A great deal of software is available to developers, even in what many would consider the small Java Platform, Mobile Edition (Java ME) space. With so much choice, it's difficult to determine which software products provide a real benefit. This technical article will highlight two products that improve the life of the Java ME developer by adding support for source-code management and application deployment. The Problem
A source-code management (SCM) product manages multiple versions of project files, allowing you to save new versions, revert to older versions, and compare versions. This is valuable feature when your last change resulted in the introduction of a regression -- a technical term for "You just added a bug to the project." Most newer SCMs go well beyond the versioning of individual files present in the original SCM -- the source-code control system (SCCS) developed at Bell Labs. Every developer should use SCM, even for small projects. The small project inevitably turns into a larger project, even if the incremental growth is merely fixing bugs or adding features. The ability to track and manage software over time is a key factor to achieving success. Application deployment can be problematic: getting the right files -- Java Descriptor (JAD) and Java Archive (JAR) -- to the right place, somewhere below the document root (docroot), on some web server. It's much easier to have an automated solution than to have to remember a manual procedure at the end of a development iteration. This technical article uses the following components:
Subversion
Subversion, often called SVN, is a popular open-source SCM system that runs on a large number of platforms. For this article, the SVN server runs on a Sun Ultra 25 workstation, and the client software runs under Windows XP. The server installation used the packages available from Sunfreeware.com, a popular site for open-source packages that are available for a long list of Solaris OS releases. To install, I simply downloaded I store all my SVN repositories in a single directory. This simplifies the SVN server runtime environment. It also facilitates backup of the various repositories. The server is started with the system using the
This is hard linked to Web Server
I use Sun Java System Web Server 7.0. The installation is standard for Solaris OS: I set the target directory to Netbeans IDE supports Web-based Distributed Authoring and Versioning (WebDAV) as one of its deployment protocols, and the web server supports WebDAV. So I used WebDAV as the MIDlet suite deployment protocol. Once the server was up and running, I followed these configuration steps to enable the WebDAV deployment of MIDlets through Netbeans IDE:
The We need some place under the web server's docroot from which to serve our JAD and JAR files. I chose the directory name of jadpool, a play on the phrase gene pool. Creating the directory on the server is simply a matter of using this code as user root:
The result is shown in Figure 1.
Authentication
Note that I did not create any groups, and no Access Control Lists (ACLs) were created or modified. WebDAV
Next I needed to create a WebDAV collection at the virtual server level. Again using the Web Server Admin Console, I drilled down to the Configurations > peg > Virtual Servers > peg page and selected the WebDAV tab as shown in Figure 3.
Selecting New brought up a New WebDAV Collection pop-up window. I specified the URI as
Clicking Next led to the Access Control page, as shown in Figure 5. Being security conscious, I restricted access by selecting the "Allow the following users in the authentication database" option and listed myself in the list of user IDs.
One more Next and I was on the Review page as shown in Figure 6. A quick review of the parameters and a daring click on Finish created the collection.
I was able to confirm my
MIME Types Figure 8 shows the result on peg.
At this point, the server side is installed, configured, and running. If the server is restarted, the web server and Subversion services will be restarted as well. Now let's turn to NetBeans IDE. NetBeans IDE
Adding Subversion support to NetBeans IDE requires two very simple steps. First, add the Subversion module by using the Tools > Update mechanism. Find SVN in the list, add it to the updates list, click a few more times, and it's downloaded and installed. You will also need to download a Subversion client for Windows. I downloaded prebuilt binaries from subversion.tigris.org and installed them. Finally, restart NetBeans IDE so that it finds the Subversion client software you just installed. Once you have restarted, you'll notice that Subversion appears on the project right-click menu and in the NetBeans IDE menu bar, as shown in Figure 9.
SVN Import Use the following as root:
The password file should end up looking something like this:
where
This allows only user root or group root the ability to read the file. Now you're ready for the initial check-in, which NetBeans IDE calls an import. To start the process, go to the menu bar and select Subversion > Import into Repository. NetBeans will then take you through three steps. First, you specify the repository and authenticated user, as shown in Figure 10.
Second, NetBeans asks for the repository folder location, as shown in Figure 11.
Finally, NetBeans shows you the list of files it will import, as shown in Figure 12.
A few Nexts and a Finish and your source is safely saved into the Subversion repository. SVN Check-Out Once checked in, the project can be checked out by any Subversion client. Under the NetBeans IDE menu, select SVN > Checkout, and the Checkout window will appear. Enter the Repository URL. In this case, we use the internal URL
Next, select which folders to check out, as showin in Figure 14. The Browse option is great for visually examining the repository to select content. Once you have selected the checkout content, click Finish.
NetBeans IDE will detect that you were checking out a project and give you the option to open the project. Select Open Project, as shown in Figure 15.
Once the project is open, select Clean and Build Main Project to make certain that you have all the pieces in working order. You can now make whatever modifications you have planned to the source. Add features, fix bugs, or tune algorithms in your own project space. You can use the emulator to test your changes before deployment using the Run > Run Main Project menu item. Deployment This is where that sometimes difficult process becomes easy. Deployment of a MIDlet suite requires putting a JAD and JAR file under the docroot of some web server. The JAD file describes the MIDlet suite that is contained in the JAR file by using MIDlet attributes. The article Retrieving MIDlet Attributes provides greater detail on JAD file syntax and contents. Eight attributes are required in the JAD file to define a MIDlet suite that can be successfully installed on a device. The JAR file contains the MIDlet suite and all its required resources. NetBeans IDE's automated deployment feature will not only install the files on the web server, it will automatically generate a correct JAD file. Note that any user-added content under the Application Descriptor category will also be added to the generated JAD file. The first time you go through the automated deployment process, you have to supply all the form data in the Deploying category of the project properties. Select the WebDAV deployment method, and supply the server name or IP address with port number, the target directory, and the WebDAV user-password pair. On the web server, all JAD and JAR files are kept in one directory:
Once you have populated all the Deploy category data, right click on the project and select Deploy to push the JAD and JAR files to the server. If you have correctly configured the server, the deployment process completes in less than one second. Download
The final test is installing the application to your device OTA from your web server. This process will vary for each device, but the steps are essentially the same:
If you are interested in more extensive on-device and on-network testing, Mobile Complete is one company that sells just such a service. Pick a carrier, a location, and a device, and you can test your application live in the field with this service. Mobile Complete has been at the JavaOne conference in the past and is sometimes at Sun Tech Days events. Conclusion
I was somewhat skeptical when I started investigating the tie-in between Subversion, NetBeans IDE, and WebDAV. Product add-ons sometimes do not work well together, fail to meet user expectations, or are awkward or difficult to use. In this case, everything worked as expected. The NetBeans Subversion module and the Mobility Pack combined with Sun Java System Web Server save time and simplify two important development tasks. Now that I have the Subversion server and Sun Java System Web Server installed on my Ultra 25 workstation, I will continue to use them on subsequent projects. | |||||||||||||||||||||||||||||||||||
|
| ||||||||||||