开发者

how to set Server IP Address in j2me(MIDP 2.0) Jar file Dynamically?

I am working on a j2me platform. I put the Serve开发者_运维技巧r machine IP Address in j2me coding Statically. It's working fine but in case, the Server IP Address is changed, then I want to change my code in the jar file placed in the mobile.

So, it is not good way to do each time the server IP changed.

Please give me a better way for dynamically assigning the server IP address in my j2me code whenever server ip address changed?


you can add server address in JAD file as custom properties like.

ServerAddress: http://example.com

and you can read this url in your code.

String url= MIDlet.getAppProperty("ServerAddress");  

So if you are changing server address, you need to change url address in jad file only not in jar file.

e.g.

if you check JAD file of gmap

you can see lots of custom JAD properties including this

ServerAddress: http://mobilemaps.clients.google.com/glm/mmap


Use a domain name so that changes to the ip address will be updated. If this isn't possible or if the ip address is changing frequently you could look into Dynamic DNS providers.


You should write the ip address/url in a separate text file in your device. From your app read the url/ip address from the text file.

So if there is any change in ip address/url, you need to change only in your text file and not in your applications.

If you add the ip address/url in jad means then again you create new build (new jar - because after packaging the jar the jad file is also come under jar file) and deploy in your device the new build. So if your ip address/url is changing one means it is difficult to achiee it.

For this scenario better your write in separate text file and read from that file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜