J2me RMI HELP
hy to all,
I'm new with j2me.
I must develop an java rmi client for hp6915.
what jvm version I must download??
I downloaded Mysaifu jvm. It is rmi rmi enabled???
There is no direct RMI support in J2ME like in J2SE. You have to use something else for your communications. The most commonly used way (and in fact the only way that is mandatory in the MIDP 2.0 spec) is via a HTTP or HTTPS connection. For more information see the MIDP 2.0 spec, in particular the section about the General Connection Framework.
Similar Messages
-
Would Like To See J2ME RMI Example
I'm looking for an example of an RMI client using the CDC optional RMI package. I've looked in many books, on the web, but nothing.
I've installed the package and attempted to run a simple client I used in J2EE land. I got a classNotFoundException for EJBObject, fixed that by installing an ejb.jar then another one for classes in the jndi package. Rather than continue to increase my project size, I get the feeling I'm going down the wrong path. Some code samples would certainly help.
A corollary question is, if there is so little done in this area, should I use a different approach than RMI?Why not consider xml-rpc (kxml-rpc) or REST
i mean just a thin http client on the j2me front for communication with the server. -
Sockets in rmi, help needed
hi,
I need a help on using sockets in rmi for communication between the server and the client. I am trying to establish a communication between the server and client through sockets after the remote method call is invoked but before it is fulfilled. I my code the socket is not establishing in the client side. Do help me out at the earliest pls... thanks in advance..I am trying to use sockets inside a rmi. Still i have the problem. I cant get my client listen from the server.
First the client invokes a remote object. Before server sending the actual request of the requested by the remote object i want to make some communication between the server and client through sockets.
I created a ServerSocket in the client side. The problem I have is the ServerSocket is not listening to the server request.
Here i ve my code.I cant figure out what mistake i have done. It also dont show any error. As i am new to RMI and sockets i am in need of help. So pls do help me... Thanks in advance.
In my example i am trying to verify the password before the server downloads the file for the client. So i want the verification done through sockets and download file using RMI.
FileInterface.java
import java.rmi.*;
public interface FileInterface extends Remote
public byte[] downloadFile(String fileName) throws RemoteException;
FileServer.java
import java.rmi.*;
import java.io.*;
public class FileServer
public static void main(String []args)
if(System.getSecurityManager()==null)
System.setSecurityManager(new RMISecurityManager());
try
FileImpl fi=new FileImpl("FileServer");
Naming.rebind("FileServer",fi);
System.out.println("Server bound"+fi);
catch(Exception e)
System.out.println("FileServer: "+e.getMessage());
FileImpl.java
import java.io.*;
import java.net.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class FileImpl extends UnicastRemoteObject implements FileInterface
private String name;
public FileImpl(String s) throws RemoteException
super();
name=s;
public byte[] downloadFile(String fileName)
try
Socket soc=new Socket(RemoteServer.getClientHost(),5000);
OutputStream os=soc.getOutputStream();
PrintStream ps=new PrintStream(os);
System.out.println("Going to send message");
ps.println("Enter the password : ");
System.out.println("Sent message");
InputStream is=soc.getInputStream();
InputStreamReader isr=new InputStreamReader(is);
BufferedReader br=new BufferedReader(isr);
String res=br.readLine();
PasswordControl pc=new PasswordControl(res,br);
System.setSecurityManager(pc);
File file=new File(fileName);
byte [] buffer=new byte[(int)file.length()];
BufferedInputStream input=new BufferedInputStream(new FileInputStream(fileName));
input.read(buffer,0,buffer.length);
input.close();
return(buffer);
catch(Exception e)
System.out.println("FileImpl: "+e.getMessage());
e.printStackTrace();
return(null);
public class PasswordControl extends SecurityManager
String password;
BufferedReader br;
public PasswordControl(String password,BufferedReader br)
this.password=password;
this.br=br;
public boolean accessOk()
String response = "";
try
if(response.equals(password))
return true;
else
return false;
catch(Exception e)
return false;
public void checkRead(String fname)
if(fname.equals("sample.txt"))
if(!accessOk())
super.checkRead(fname);
throw new SecurityException("Access denied to read from the file sample.txt");
else
FilePermission fp=new FilePermission(fname,"read");
checkPermission(fp);
FileClient.java
import java.io.*;
import java.net.*;
import java.rmi.*;
public class FileClient implements Runnable {
Socket soc;
String filename;
byte[] filedata;
public FileClient(String filename, String host)
this.filename = filename;
try
ServerSocket ss=new ServerSocket(5000);
System.out.println("Created a socket"+ss);
String name = "//" + host + "/FileServer";
FileInterface fi = (FileInterface) Naming.lookup(name);
System.out.println("Got the interface "+fi);
while(true)
soc=ss.accept();
new Thread(this).start();
} catch(Exception e)
e.printStackTrace();
public static void main(String argv[]) {
if(argv.length != 2) {
System.out.println("Usage: java FileClient fileName machineName");
System.exit(0);
new FileClient(argv[0], argv[1]);
public void run() {
try {
System.out.println(soc);
InputStream is=soc.getInputStream();
InputStreamReader isr=new InputStreamReader(is);
BufferedReader br=new BufferedReader(isr);
System.out.println("Created the readers"+br);
String req=br.readLine();
System.out.println("Going to print request");
System.out.println(req);
String password=br.readLine();
OutputStream os=soc.getOutputStream();
PrintStream ps=new PrintStream(os);
ps.println(password);
filedata = fi.downloadFile(filename);
File file = new File(filename);
BufferedOutputStream output = new
BufferedOutputStream(new FileOutputStream(file.getName()));
output.write(filedata,0,filedata.length);
output.flush();
output.close();
} catch(Exception e) {
e.printStackTrace();
} -
Hi,
Can any one help me in this problem ?
I'm getting the following error When the server responses to the client call.
java.rmi.UnmarshalException! error unmarshalling return; nested Exception is
java.io.StreamCorruptedException
at sun.rmi.Server.UnicastRef. invoke
The problem is with client side When processing the server side response..
Thanks for spending ur time.Hi,
check out the official tutorial at http://java.sun.com/j2se/1.4/docs/guide/rmi/getstart.doc.html
Patrick -
Hello everyone,
I am a student and am in the process o f learning Java as part of my syllabus. A part of year work we have to a submit a live project...for that i have chosen a local organization that runs trains and provides electricity.
All the information about the orgztn will be stored in the database like customer their ID and bill, and as for trains the area, frequency, stop name code...etc.....
The customers can access the orgztns info via a mobile phone..so they can enter thier starting point and end point and the train number to borad along with the fare will be given, if the user wishes he can view a graphical route that the train will take to reach the destination(planning to use a JPEG image)...also they can view their electricity bills too and view graphical analysis of their consumption for the past one year....
I ma completely new to J2ME as well as J2EE.....Please guide me as to how will i connnect my mobile J2ME app to my remote server that will in turn connect to database and retrieve the required info and give back to J2ME app.....
how to I go on doing this...please help me as I am totally confused as to how will i build the system???
Thanks for your help.
Regards,
Abigail VenturiThat's quite a broad question. Here's the list of technologies I'd use....
You'll likely need to use a client/server methodology...
Server side: Create a servlet to connect to the database, and do all the work like route finding, image creation for the routes, etc. Store your info in a relational database like MySQL or whatever. Servlets run in a web server, I prefer jetty, but most web servers have support for Java servlets. You don't even need to use Servlets/Java, as you can use anything you want for server side. Pick what you are most familiar with php/cgi/java/etc
Mobile: Just have a front end for user choices on the device, then send the choices to the server using an HttpConnection, and retrieve the results in the stream.
The reason for doing everything on the server is simple: limited memory. If you are supposed to have a graphical representation of the route the user is going to take, you'll likely need more images than will fit on the mobile device. It depends on the detail required though. Also, a database of customers is probably too large in itself to fit on a mobile, and searching is most easily done using something like a relational database. -
Hello all,
I have fallen into a major problem. i am trying to get my first RMI system working and have looked numerous places for help. I have followed http://patriot.net/~tvalesky/easyrmi.html and cannot get passed running the client program.
The coding is the same as the tutorial, i get the following errors...
D:\RMI>java myRMIClient 10.0.0.7
Exception occured: java.security.AccessControlException: access denied (java.net
.SocketPermission 127.0.0.7:1099 connect,resolve)
D:\RMI>java -Djava.security.policy="d:\RMI\wideopen.policy" myRMIClient 127.0.0.1
Exception occured: java.rmi.NotBoundException: myRMIImplInstance
------wideopen.policy------
grant {
// Allow everything for now
permission java.security.AllPermission;
I really appreciate anyone who can help me. It is pretty urgent as i need to get this first exercise working.
Many thanks, RikuHello All,
Many thanks for your advice,
I have taken off the quotes and have tried to run the policy file on the server.
When i launch rmiregistry on command prompt it shows on firewall:
Protocol----Executable------- Remote-----------Local----------------- Sent---------Recieved
TCP______rmiregistry_____---___________Host Name:1099__0________0
I then start myRMIServer
On the command prompt it hangs on java -Djava.security.policy=d:\RMI\wideopen.policy myRMIServer 127.0.0.1
On the firewall it states:
TCP______java.exe______Host Name:1099_Host Name:1691__252________37
That TCP dissapears after a timeout but on command prompt it hangs until i press CTRL+C
I cannot explain what is happening there.
I am not experienced enough to understand the code either.
I really appreciate if you can give me more guidance on this.
Thanks, Riku :) -
Does someone know link for good tutorial on j2me ,please help
plese help i m a newbie in j2me kindly suggest tutorial which guides its reader
from grass root levelHave you looked over this:
http://developers.sun.com/techtopics/mobility/midp/articles/wtoolkit/
Good Luck
Lee -
THIS WAS MY FIRST J2ME application. I have a sony ericsson K800i phone! and can i run this application on that mobile phone
sony ericsson K800i supports MIDP2.0
this application is working in netbeans!!!!
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Midlet extends MIDlet
private Form form;
private Display display;
public Midlet()
super();
public void startApp()
form = new Form("004");
String msg = "Hello world K00000000004";
form.append(msg);
display = Display.getDisplay(this);
display.setCurrent(form);
public void pauseApp()
public void destroyApp(boolean unconditional)
form = null;
notifyDestroyed();
}I assume you mean the app doesn't work on the phone? The default settings on Netbeans won't run on most phones. Make sure the properties of your project match your phone. Your phone is probably MIDP2.0 and the default in Netbeans is 2.1.
-
hi,
im developing a small game. in that game the character jumps from one hurdel to another. i made my character to move upword and then forward to land on specific location....
here is my code to do that...
// jump up
for (i = 0; i <= 30; i++){
duckJumpSprite.move(1,-1);
duckJumpSprite.nextFrame();
// going down and forward
for (j = 1; j <= 30; j++){
duckJumpSprite.move(1,1);
duckJumpSprite.nextFrame();
}when executed it obviously do not shows any character between jump starting position to jump ending position as it goes too fast in paint() method...
i just c character in my starting position and then in ending position....
now question is that how do i make the intermediate states of the jump visible on the screen.
plz help me
thankshi,
ive implemented it this way...
int distanceX = 1;
int distanceY = 1;
new Thread (new Runnable(){
public void run(){
while(true){
try{
Thread.currentThread().sleep(10);
if(up){
// we are Moving up
//System.out.println("ducksprite Y coord >>> "+duckSprite.getY()+" jumpheight >> " + jumpHeight );
if (duckSprite.getY() > jumpHeight ){
duckY -= distanceY;
duckX += distanceX;
}else
if (duckSprite.getY() >= jumpHeight ){
duckY += distanceY;
duckX += distanceX;
System.out.println("Hello going down ");
up = false;
else if ((duckSprite.collidesWith(backTiledLayer,true)) || duckSprite.collidesWith(frontTiledLayer,true)){
break;
else if (!up){
System.out.println("Hello going down permianately");
// we are moving down
duckY += distanceY;
duckX += distanceX;
duckSprite.setPosition(duckX,duckY);
duckSprite.paint(getGraphics());
} catch(Exception exception){
System.out.println("exception came in jump thread >>> ");
}}).start();is it ok
almost the same as u did but i did this before i saw ur reply... -
Rounding Double in J2ME, need help
hi....
i using J2me to develop scientific calc.
but i have problem with rounding the double result.
when using J2SE i can use DecimalFormater...
is there something like that in J2ME ???
tanks...1. Convert the double to a string using Double.toString(yourDouble)
2. Use yourString.substring and indexOf(yourString, ".") to get the part you need. Concatenate trailing zeros if needed.
3. Convert the resulting string to a double using Double.parseDouble(YourResultString)
The string manipulation will be different depending on whether you want to round to a certain number of decimals or a certain number of significant figures.
If you need a code segment pls supply more details, have tested this approach and it works.
Regards, Darryl -
I'm getting the following error which to me i think it means it is unable to find the record. As you can see i've created the record successfully and i can store the record too but when i try to retrieve the record i get the following error:
Record store now has 1 record(s) using 80 byte(s) [999807 bytes free]
javax.microedition.rms.InvalidRecordIDException
at javax.microedition.rms.RecordStore.findRecord(+98)
at javax.microedition.rms.RecordStore.getRecord(+22)
at EventsManager.commandAction(+194)
at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(+186)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+57)here is my code for display record
else if (command == view)
try
for (int i=0;i<rs.getNumRecords() ;i++)
title = new String("");
with = new String("");
byte b[] = rs.getRecord(i);
String str = new String (b,i,b.length);
int len = str.length()+1;
display_Events(len);
catch (RecordStoreException exc)
exc.printStackTrace();
catch (Exception exca)
exca.printStackTrace();
}displayEvents method code
public void display_Events(int len) throws Exception
int recordSize=0;
if (len<rs.getSize())
recordSize = rs.getRecordSize(len);
if (recordSize > 0)
String value = new String(rs.getRecord(len));
// Report progress to the console
System.out.println("Retrieved record: "
+ len + " Value: " + value);
}can someone please tell me what i am doing wrong please
thanks in advance
Edited by: Asad86 on Mar 29, 2009 1:49 PMHi,
Record identifier is NOT record index. When reading a entire record store you'd better use
rs.enumerateRecords ()Hope that help
Jack -
Hello everyone,
I am trying to compile a beginners very first .java file and have run into difficulties.
The cldc/midp/jdk versions are shown below on the variables:
CLASSPATH: C:\J2ME\midp1.0.3fcs\classes;.
MIDP_HOME: C:\J2ME\midp1.0.3fcs
PATH: C:\J2ME\j2me_cldc\bin;C:\J2ME\midp1.0.3fcs\bin;C:\j2sdk1.4.2_02\bin;
It has come up with 14 errors on the DOS prompt, the first error:
'package javax.mircroedition.midlet does not exist'
I gave it the javac -bootclasspath command and location of the classes, but it gives me the impression it still doesnt know where it is...
What could be wrong? i've done my research and cannot find out what's the issue; i even downgraded from midp2.0fcs just incase.
Many thanks for your time,
RikuIt has come up with 14 errors on the DOS prompt, the
first error:
'package javax.mircroedition.midlet does not exist'Is this a typo? If not, you misspelled "microedition".
CLASSPATH: C:\J2ME\midp1.0.3fcs\classes;.I don't know the directory layout of this edition, but it looks like it should beC:\J2ME\midp1.0.3fcs\classes.zip;. -
Hi All!
I'm new to java, but i want to build J2ME (MIDP) applications.
I can write *.java files and run it after compiling.
But i want to write low-level APIs (games) and i have an example from
which i can start. It's a dog animation and it consists a Doggy.java and a DoggyMIDlet.java and some *.pngs. Now how can i compile thesse files into one .jar??? I have an Ant, and a Wireless Tollkit but i cant use any of them :(( Where can i find some tutorials to j2me midp (game) writing?Thanks for the replies in advance.
WolfIn the "wireless toolkit(wtk104 - last version)" dir there are 3 games which you can study.
catalin -
Hi
I have an client
- Client.java
and two servers
- ServerOneInterface.java
- ServerOneImpl.java
- ServerTwo1Interface.java
- ServerTwoImpl.java
The client can communicate with the servers fine, but how do i make the servers communicate with each other? What is the idea between making the servers communicate with each other?
Thankswhy not use the same concept and make each server behave as a client of the other...
-
How to implement VoIP over SIP in J2ME
Hi All,
This is kapil from India and i want to implement VoIP over SIP in j2me.Any help will be appreciated.
I know about SIP API in J2ME. I want to use VoIP over it.Please help.I will be grateful to you.
regards
kapilWhy don't you give us the money your Boss pays you.. then we'll see what can be done ;)
Seriously, it might be smart to start your own research first. Check out what VoiP and SIP are all about, and the check how it fits into J2me.
Maybe you are looking for
-
My iphone 3GS has gotten frozen while attempting to download the OS 5.1.1. It is stuck on the picture with the cord going up toward the itune logo. How can I repair this problem?
-
Difference in GR and invoice posting Prices with respct to Purchase Order
Dear All, We have facing a problem while posing a MIRO for our client . The background is as follows for the Import PO (Document currency is GBP) 1) Rate of Exchange is 1 Euro = 0.84260 GBP....for August 2010 maintained in OB08 2) PO Rate for item A
-
I hope you can tell me I'm missing something. I have never been able to sort any of my photos on my iPad or iPhone to descend by date. This is incredibly frustrating trying to scroll through 4 thousand photos to find one I took the other month. I ha
-
Hi everyone: I would like to know which one is faster: The outer join or the function a select statement. Thanks,
-
Free Transform Vs. Image Size - Quality Impact?
I'm using Photoshop CS3 and I have a quick query regarding the difference in image quality between resizing an image using 'Image Size' compared to 'Free Transform'. I'm laying out several individual photographs on to a page (with some precision) and