• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to MIME encode a jar file?

 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

I don't know if this is the right thread to put this question into but since i am kind of stuck at the issue therefore i am putting the question here.

Actually i want to put the jar file into the XML and since the jar file is a binary data i need to MIME encode it. I am stuck at the issue that how to encode the jar file and put that file into the XML. Please provide me with some sample code or links or some guidance on how to achieve this goal?

Also if it is not the appropriate thread please move it to more appropriate thread.

Thanks & Regards
Girish
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why on earth would you like to encode a jar-file into an xml-file?

But anyway, the mime-codes f�r JAR-files are:

application/java
application/java-archive
application/x-java-archive
application/x-jar

You can check the mime-types of a file at http://mindprod.com/jgloss/mime.html

But the best aproach, in my humble opinion, is to have a URL in the XML-file that points to a server from where the jar-files can be downloaded. That is the way it is done in Eclipse Update manager, IntelliJ uppdate manager and other similar applications.
 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your reply. But the actual issue is that my client want me to send the jar file using an SMS so that there is no need for GPRS on the other end(Mobile user). That is why i have to send the file itself in an XML.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to send a JAR file encoded in XML via an SMS message? Ofcourse I don't know what your exact goal is with this, but it sounds very strange.

SMS messages are limited to 160 bytes, that's way too small for any serious amount of data.

Is the receiving system a mobile phone? How is a mobile phone going to process an SMS message containing XML with an encoded JAR file?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also note that the classes in a jar are binary data. XML is required to be character data (UNICODE). In order to pass binary data in XML you will have to base64 encode and decode, just setting the MIME type is not enough. In base64, 3 bytes turn into 4 character, thus limiting the size even more.

Bill
[ September 04, 2008: Message edited by: William Brogden ]
 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the receiving system a mobile phone? How is a mobile phone going to process an SMS message containing XML with an encoded JAR file?


Well yes the receiving end is a Mobile. Well I am not going to send the jar file in one SMS.Can't I send it in multiple messages as we know that when the data length extends the 160 characters the SMS is broken into multiple parts and when it is received at the mobile end it is assembled into one message. So why don't we apply the same concept in case of receiving jar file. Can't the mobile phone recognize the fact that the content is a jar file and treat the content accordingly.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Girish Vasmatkar:
Can't the mobile phone recognize the fact that the content is a jar file and treat the content accordingly.

Suppose you have a JAR file of 20 KB, which is very small. If you break that into parts of 160 bytes, that would be 128 SMS messages! Mobile phones normally have a limit to how many SMS messages they can store. I think mine can't store more than 100 or so at one time.

The mobile phone will ofcourse not automatically recognise that the content is a JAR file and do something with it.
 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got the point. I am dumping the idea of SMS. Thank you all for taking time out of your schedule. But here is another question.
Can i send the file using MMS? But my fear is that many phone softwares do not provide facility to send the jar file. Only image files, sound files or video files are displayed while browsing for the content to be sent over MMS. So can we write a program which follows MMS specifications and send a jar file OTA.

Thanks & Regards
Girish Vasmatkar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic