When you go live with a project, you may not want to manually edit the server URL on every phone. You can edit the .jar (the mobile client) file before putting it on the phone so that your server URL is the default URL in the mobile application.

To do this you will need java installed on your desktop machine where you are editing the .jar

Open a terminal / command prompt:

  • Windows: from the start menu, go to run a program and type cmd
  • Mac: Terminal is in the utilities
  • Linux: gnome-terminal / xterm / terminator etc.

From the command prompt type:
$ java -version
If you see something like
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode)
you should be able to update your jar.

Extract the default.properties file from the jar

At the command prompt, navigate to the location of your mobile client – e.g. mforms-midlet-2.4.8-me.jar

$ jar -xf mforms-midlet-2.4.8-me.jar defaults.properties

(Don’t forget to use your midlet name)

This extracts the defaults.properties file from your jar and you should now see it in the folder you are in with your mforms-midlet-2.4.8-me.jar. If you omit defaults.properties from the end of the command it will extract the entire contents of the jar which is a lot of files but is fine and you can continue with the following instructions

Edit the default.properties file

Open default.properties in your favorite text editor (not Word) e.g. notepad, gedit

It should contain one line:
httpUrl=http://localhost:8080/openxdata/mpsubmit

Edit this to be your server – do not forget the /mpsubmit at the end of the URL for example:
httpUrl=http://www.myopenxdataserver.net:8080/webapp-1.16.7/mpsubmit

When you are finished, save this file back to where you opened it

Update your jar with your new defaults.properties

At the command prompt, navigate to the location of your mobile client again

$ jar -uf mforms-midlet-2.4.8-me.jar defaults.properties

This is the same as before but with -uf instead of -xf

(Don’t forget to use your midlet name)

Done!

Copy your jar onto your phone and you should now have a new default URL.