Sending Java Applications to a mobile phone

Introduction

Most mobile phones support Java applications these days. There are both payed and free applications around. This document describes how to upload a Java application to a mobile phone through the air ( GSM / GPRS / UMTS network ), instead of using a datacable.

There are two ways to do this, the first method is by attaching the JAR file to a slide in a MMS message. The second is by sending a WAP push message that redirects the phone to the JAR file hosted on your website. The best is to use the second method, most networks have a size limit when using MMS, and applications may become larger then this limit (most providers use 300K). There are some providers which remove applications from MMS messages for security reasons.

Both methods are discussed in this article, and how to implement them using the ActiveXperts SMS and MMS toolkit

Sending Java applications by MMS

When sending a small application to a small range of phones, this method would be the easiest to implement. All that is needed is the Java application itself, the ActiveXperts SMS and MMS toolkit and a GPRS or 3G modem with SIM card connected to your PC.

Some phones can install an application when only the JAR file is received. Other phones also need the JAD file to be sent. Not all models are able to install applications that are sent via MMS, in this case, use the WAP Push method instead.

The following code sample shows how to send an Java application using a MMS message. To run this code, you must have the SMS and MMS toolkit downloaded and installed on your computer. You can download a fully functional 30 day trial version here.

Option Explicit

' Declare objects
Dim objMessage, objConnection, objSlide

' Create objects
Set objConnection                 = CreateObject ( "ActiveXperts.MmsProtocolMm1" )
Set objMessage                    = CreateObject ( "ActiveXperts.MmsMessage" )
Set objSlide                      = CreateObject ( "ActiveXperts.MmsSlide" )

' Set 'Device'
objConnection.Device              = "Telit HSDPA USB Modem"

' Set 'LogFile'
objConnection.LogFile             = "MmsLog.txt"

' Set provider properties GPRS APN, WAP Gateway and MMSC Server Address.
' Please check https://www.activexperts.com/mmstoolkit/mmsclist, or ask your provider for
' your provider's settings
objConnection.ProviderAPN         = "MMS"
objConnection.ProviderAPNAccount  = "tmobilemms"
objConnection.ProviderAPNPassword = "tmobilemms"
objConnection.ProviderWAPGateway  = "http://10.10.10.11:8080"
objConnection.ProviderMMSC        = "http://t-mobilemms"

' Mmslide: Add the Java application as attachment
objSlide.AddAttachment            "application.jar"

' Clear Message
objMessage.Clear    

' Set Message Subject
objMessage.Subject                = "Java Application"

' Set Message Recipient
objMessage.AddRecipient           "+31647134225"

' Add the slide created above.
objMessage.AddSlide               ( objSlide )

' GPRS/UMTS: connect now
WScript.Echo "Connecting..."

objConnection.Connect

WScript.Echo "Connect, result: " & objConnection.LastError & " (" & _ 
             objConnection.GetErrorDescription ( objConnection.LastError ) & ")"
If ( objConnection.LastError <>> 0 ) Then
   WScript.Sleep 3000
   WScript.Quit
End If

' Send the message
WScript.Echo "Sending message..."

objConnection.Send ( objMessage )

WScript.Echo "Send, result: " & objConnection.LastError & " (" & _ 
             objConnection.GetErrorDescription ( objConnection.LastError ) & vbCrLf & _
             "Provider response: " & objConnection.ProviderResponse & vbCrLf & _
             "MessageID: " & objConnection.MessageId

' GPRS/UMTS Disconnect
objConnection.Disconnect

WScript.Echo "Disconnected."
WScript.Echo "Ready."

Sending Java applications using WAP Push

WAP Push, has been incorporated into the specification to allow WAP content to be pushed to the mobile handset with minimum user intervention. A WAP Push is basically a specially encoded message which includes a link to a WAP or WWW address. WAP Push is specified on top of WDP (WAP Datagram Protocol, resembled the UDP protocol in the Internet); as such, it can be delivered over any WDP-supported bearer, such as GPRS or SMS.

The following code sample shows how to send an Java application using a WAP push message. To run this code, you must have the SMS and MMS toolkit downloaded and installed on your computer. You can download a fully functional 30 day trial version here.

Option Explicit

Dim objGsmProtocol, objSmsMessage, objWapPush, objSmsConstants

Set objGsmProtocol       = CreateObject( "ActiveXperts.SmsProtocolGsm" )
Set objSmsMessage        = CreateObject( "ActiveXperts.SmsMessage" )      
Set objWapPush           = CreateObject( "ActiveXperts.SmsDataWapPush" )  
Set objSmsConstants      = CreateObject( "ActiveXperts.SmsConstants" )

objWapPush.URL           = "http://www.myserver.com/application.jar"
objWapPush.Description   = "Application"
objWapPush.SignalAction  =  objSmsConstants.asWAPPUSHSIGNAL_MEDIUM
objWapPush.Encode 
                                                        
WScript.Echo "Encoding WAP Push, result:" & objWapPush.LastError
If( objWapPush.LastError <> 0 ) Then
   WScript.Quit
End If

objGsmProtocol.Device     = "Telit HSDPA USB Modem"

objSmsMessage.Recipient   = "+31625044454"                                 
objSmsMessage.Format      = objSmsConstants.asMESSAGEFORMAT_DATA_UDH  
objSmsMessage.Data        = objWapPush.EncodedMessage 

objGsmProtocol.Send( objSmsMessage )

WScript.Echo "Sending message, result: " & objGsmProtocol.LastError