• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to MIME encode a jar file?

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 326
Android Mac OS X Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic