Can I create a .jar file on FFS? | Telit Cinterion IoT Developer Community
September 8, 2015 - 11:01am, 7813 views
I try to open a jar file using following code:
FileConnection fconn = (FileConnection) Connector.open("file:///a:/test.jar", Connector.READ_WRITE);
However it always return
"Application not authorized to access the restricted API:javax.microedition.io.Connector.file.manufacturer"
How can I access a jar file without security?
You are probably updating the MIDlet application as I understand and not the module's firmware.
This exception is because for security reasons it is not possible to copy, rename or read the jar file.
When you install the MIDlet from some place on the flash file system you can even delete the jar and jad files that were used for the installation but you probably leave them for your backup feature. I think that you could deal with this security problem by just installing the new application from some other folder than the previous one. You wouldn't need to copy the jar file then. After the operation you would be able to rename the folders according to your *****.
Or you would be able to copy the jar file if it didn't have the jar extension. But if it already has the jar extension you can't change it any more. So you are able to download to the module the file and copy it to any place, than change the extension to jar.
I hope that it will help to adopt your solution.
Yes, I am trying to upgrade the midlet.
The issue is that I need to upgrade the midlet often and I need to ***** the old midlet because It would fill the memory fast and I could do only few upgrades.
Is there a way that I could give the right to write in jar file when I generate .jar file?
Maybe I don't understand the solution - you want to backup the application on the module before uninstalling it - if you don't have the copy of this application (that was used to installation) because you have deleted it just after installation to save the space for other data how would you like to make the backup before uninstallation? The application is installed in the hidden space of the file system and you are not able to copy it from there.
This feature was introduced to protect the MIDlet from being ****** from the module so you can only delete the jar file.
The solution works like that:
1 - The new jar is received.
2 - The old jar is saved temporarily for backup
3 - The new jar is installed
4 - If everything is ok, the old firmware is *****d for saving space in memory. Otherwise, if something goes wrong, the old fimrware is restored and the new one is *****d.
I am not able to ***** the jar file too. Should it work?
There is some permissions in Application descriptor (Signing option), what does it means? Would it be possible to give the permission for FileConnection class?
You should be able to delete the jar file. if you do it in Java application you need to open the file connection with READ permission only.
There is no way for the user application to grant permissions to read or copy jar files.
I understand that you only want to keep the old application until it will be possible to successfully start the new one and right after that the old one will be deleted. What I don't understand is (point 2) how you want to restore the currently installed application for backup purposes as it is installed in a hidden space of the file system where your application has no access to.
What do you mean when you say that the application is installed in hidden space? The application is in the file system so if it is necessary to restore it (because the new application did not start correctly), the boot application would install and start (at^sjam) the old application again. However, in order to have this mechanism, I really need to be able to ***** a jar file.
To install the application you copy it to the file system of the module and install it with AT^SJAM=0,"a:/AppName.jad","" command. During the execution of this command the application is copied to the hidden space of the file system. In the end you can delete the jar and jad file from the file system and the application will still be installed and you will be able to run it until you uninstall it with AT^SJAM=3,"a:/AppName.jad","".
You are not able to access this hidden space and copy the application from there and that's why I suggested before that you probably don't delete the jar and jad used for the installation but keep it for the backup.
To refer to your application in AT^SJAM command you use the path, but it is just a path from where the application was installed and not the actual path to the application. For instance when you install the application from the network (by the provided OTAP feature) this path will start from "http://".
You should be able to ***** the jar file in a way that I have described above. Please use the Connector.open() method variant that takes the access mode parameter "open(String name, int mode)".