J2ME: accessing web over USB connection & reading files

B

Branko Kaucic

Hi all.
I got Dell Axim X30 Low (non-wireless, just IR and USB connection) and I
have the following problems.
I need to make a program in MIDP 2.0 (I installed IBM Websphere Micro
Edition aka J9) where I get the content of some web page. What I found
out: if I use IE that is installed on PDA, then I can browse on internet
as much as I would like. However, if I use Connector.open(URL) from MIDP
then PDA asks me about using air time. And it doesn't work. Must I
configure something that I am not aware of?

Also I have another problem. From the PC I would like to copy some files
on PDA and I would like to read their content in MIDP midlet.
Has anyone done anything like this? If file is packed inside jar then
there is no problem. On the contrary, files will be put in My Documents
folder.

Thanks in advance,
Branko
 
D

Darryl Pierce

Branko said:
I got Dell Axim X30 Low (non-wireless, just IR and USB connection) and I
have the following problems.
I need to make a program in MIDP 2.0 (I installed IBM Websphere Micro
Edition aka J9) where I get the content of some web page. What I found
out: if I use IE that is installed on PDA, then I can browse on internet
as much as I would like. However, if I use Connector.open(URL) from MIDP
then PDA asks me about using air time. And it doesn't work. Must I
configure something that I am not aware of?

I would assume so. Check the IBM website and knowledge base to see how
you would do that.
Also I have another problem. From the PC I would like to copy some files
on PDA and I would like to read their content in MIDP midlet.
Has anyone done anything like this? If file is packed inside jar then
there is no problem. On the contrary, files will be put in My Documents
folder.

By default, MIDlets cannot access files outside of their own security
sandbox. So, the answer is a likely "no" you won't be able to
arbitrarily access files in the My Documents folder on the device.
 
B

Branko Kaucic

Darryl said:
I would assume so. Check the IBM website and knowledge base to see how
you would do that.

I couldn't find anything and that was why I posted this e-mail:(

By default, MIDlets cannot access files outside of their own security
sandbox. So, the answer is a likely "no" you won't be able to
arbitrarily access files in the My Documents folder on the device.
I read that somewhere too, but why then Java Wireless Toolkit has a demo
called PDAPDemo which demonstrates how you can read files from file
system if this doesn't work:( It works only on emulator.
 
J

JScoobyCed

Branko said:
I read that somewhere too, but why then Java Wireless Toolkit has a demo
called PDAPDemo which demonstrates how you can read files from file
system if this doesn't work:( It works only on emulator.

If you check the sources, it shows:
import javax.microedition.io.file.*;

and the comments show:
/**
* Demonstration MIDlet for File Connection API. This MIDlet
* implements simple file browser for the filesystem avaliable to the
* J2ME applications.
*
*/

I guess this is a separate API that each device manufacturer decides to
include or not.
 
J

JScoobyCed

Branko said:
Hi all.
I got Dell Axim X30 Low (non-wireless, just IR and USB connection) and I
have the following problems.
I need to make a program in MIDP 2.0 (I installed IBM Websphere Micro
Edition aka J9) where I get the content of some web page. What I found
out: if I use IE that is installed on PDA, then I can browse on internet
as much as I would like. However, if I use Connector.open(URL) from MIDP
then PDA asks me about using air time. And it doesn't work. Must I
configure something that I am not aware of?

Also I have another problem. From the PC I would like to copy some files
on PDA and I would like to read their content in MIDP midlet.
Has anyone done anything like this? If file is packed inside jar then
there is no problem. On the contrary, files will be put in My Documents
folder.

Thanks in advance,
Branko

Alternatively, there is a possible hack to save the files that the
MIDlet handles to the file system, and back from the file system to the
MIDlet.
Now, using it is a bit tricky and and user-friendly.
It uses a webserver MIDlet: this MIDlet opens a ServerSocket on port 80,
and provides in the page two forms: one to upload a file, one to
download a file.
The uploaded file will reside in the RMS of the JVM.
The downloaded file can be saved to the file system through the browser.

You will need to write an utility that can read or write a file (array
of bytes) to the RMS given a filename.

Now this is just conceptual, I didn't have time to test it. Another
trick would be to send it to yourself through bluetooth.

Yeah... I have crazy (and maybe impossible) ideas :)
 
D

Darryl Pierce

Branko said:
I read that somewhere too, but why then Java Wireless Toolkit has a demo
called PDAPDemo which demonstrates how you can read files from file
system if this doesn't work:( It works only on emulator.

There is an optional API for accessing files on a device, but it's just
that: optional. Not all devices will provide that API set, and for those
that don't you're limited to your own security sandbox.
 
D

Darryl Pierce

JScoobyCed said:
If you check the sources, it shows:
import javax.microedition.io.file.*;

and the comments show:
/**
* Demonstration MIDlet for File Connection API. This MIDlet
* implements simple file browser for the filesystem avaliable to the
* J2ME applications.
*
*/

I guess this is a separate API that each device manufacturer decides to
include or not.

They're the remains of what was the PDA Profile (JSR-75), which became
two sets of optional APIs: File Connection and PIM APIs. They're
*optional* APIs, though.
 
B

Branko Kaucic

Yes, unfortunately it seems that it is optionally. However,
I still hope that I made a mistake in path string to the file :)
Well, during these days I also encountered the following
problems:
1) if I copy files that are in PDA's directory recordStores
to PC, how can I read them on PC? Has anyone any information about
the format of the record store?
2) if I want to transfer information from PDA to PC by using
sockets (because I can not expect that user has www server on its
PC side), which IP number must I use for the connection?

Regards
B
 
D

Darryl Pierce

Branko said:
Yes, unfortunately it seems that it is optionally. However,
I still hope that I made a mistake in path string to the file :)
Well, during these days I also encountered the following
problems:
1) if I copy files that are in PDA's directory recordStores
to PC, how can I read them on PC? Has anyone any information about
the format of the record store?

The format is an OEM implementation detail and not in any way addressed
by the MIDP specification.
2) if I want to transfer information from PDA to PC by using
sockets (because I can not expect that user has www server on its
PC side), which IP number must I use for the connection?

That depends on how you're connecting your phone to your PC, and whether
the handset supports connections of that type.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top