File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes Java and C++ interaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Java and C++ interaction" Watch "Java and C++ interaction" New topic
Author

Java and C++ interaction

karan chopra
Greenhorn

Joined: Apr 04, 2006
Posts: 3
Hi All,

I am a newbie to Java/J2ME and have a question and would really appreciate if someone could answer it. Bassically, I want to know if other than JNI, there is a way to get an application written in J2ME for java devices (example, blackberry) to make calls to external functions in a C++ dll on the same device? I excluded JNI because as far as I know blackberry does not support JNI (please correct me if I am wrong here).
Any inputs would be much appreciated.

Thanks
Karan
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Because J2ME application are run in a asandbox. You are very limited to how you get to external things, like the Connection Framework for getting HttpConnection, SocketConnection. If on a device there are C apis, only those apis exposed by the manufacturer and in a Jar file will be allowed. Anything else will be blocked to protect the users phone.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
karan chopra
Greenhorn

Joined: Apr 04, 2006
Posts: 3
Originally posted by Mark Spritzler:
Because J2ME application are run in a asandbox. You are very limited to how you get to external things, like the Connection Framework for getting HttpConnection, SocketConnection. If on a device there are C apis, only those apis exposed by the manufacturer and in a Jar file will be allowed. Anything else will be blocked to protect the users phone.

Mark


Hi Mark,

Thanks for the reply, pardon my ignorance but can you please explain what exactly do you mean by saying "J2ME application are run in a asandbox". Basically my situation is as follows:
We have an application written in C++ for Mobile devices, and it has an exe and quite a few dlls, now we are planning to make a foray in the java devices segment, and I am investigating the possibility of code reuse of our C++ dlls (thus reducing the work involved of having to rewrite the entire code). If this is possible then we would only have to write the exe in java. But I read that blackberry doesn't support JNI, hence I was looking for an alternative. But do you know if blackberry supports C++ dlls at all or not?
Once again, really appreciate your response.

Thanks
Karan
Pradeep Gudipati
Greenhorn

Joined: Mar 09, 2006
Posts: 16
quote:
Originally posted by Mark Spritzler:
"Because J2ME application are run in a asandbox." You are very limited to how you get to external things, like the Connection Framework for getting HttpConnection, SocketConnection. If on a device there are C apis, only those apis exposed by the manufacturer and in a Jar file will be allowed. Anything else will be blocked to protect the users phone.

Mark

J2ME applications are run in a Sandbox environment that is they are not allowed access to features outside the JVM with User written applications.
Most of the devices that are java enabled do not support .dll files. The whole application has to be in a jar format.
Whereas some Symbian devices do support both,...

will get back with the details of which devices support C++ in their JVMs later.
karan chopra
Greenhorn

Joined: Apr 04, 2006
Posts: 3
Hey Pradip,

Thanks a lot for the reply, so is there no way by which I can reuse the C++ dlls on a pure java phone (non-symbian)? This would mean that we have to rewrite a lot of code in java. Hmm..Also if you could send me the list of phones that you mentioned support C++ dlls then that would be great.

Thanks
Karan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java and C++ interaction