Rohan Amin

Greenhorn
+ Follow
since Mar 19, 2008
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rohan Amin

How much time does it take to get the certificate from sun microsystems?
15 years ago
Ah well if i enter something that is not in the array and that would not be part of the array even after sorting i mean if there is no insertion point for the element then in that case it returns the value of -6. I modified the code to find 'a' and 'o' and then in that case it returns value -6.
Well i dont know how keys came into picture in case of arrays. Well as you see in the code the array is filled with A B C D F. Now what i understood after reading the book is that for the array to be sorted it should be E in place of F. so the insertion point is (-(4)-1) ie 5 and thats what the code ouput is. If my understanding is wrong just clarify this and let me know what changes have to be done in the code so that it prints out -6.
Given a properly prepared String Arrray containing five elements which range of results could a proper invocation of Arrays.binarySearch() produce?

Shouldn't the answer be E ie -5 to 4 rather than -6 to 4. I wrote a small code to test this. Let me know if i am correct or is there something that i didnt understand well.


Well the ouput for the above program is -5.
Well thats what i think. I think both the codes get past the compiler but at runtime the actual object is checked and so at the first case it fails whereas in the second case it works and so the program works.

Thanks for your reply.
Well i am not sure as to whether it should or should not throw exception. My guess is that it basically points to the sub class object and so even if it is being referred to by super class instance it gets downcasted. Well i just wanted to confirm whether my understanding is correct or not because this particular example has not been covered in the book but the topic actually starts with a similar example. Animal a = new Dog();
The K&B covered the following example for polymorphism.
.
The following compiles but later gives an exception.

But the book does not cover this example.

.
The following compiles but gives no exception. I guess it has something to do with the type of object the reference variable refers to. This is the complete code



Please let me know about this.
Also on page 476 the topic of regular expression there is an example

source: "12 0x 0x12 oxf oxg"
index: 0123456789012345

regex would return 6 and 11. Well i guess the index reverts back to 0 just for readability purposes. Let me know if this is the case or its indeed a typo.
Use a debugger and you will see that the functions are evaluated first. So it prints out a,b,c and then it evaluates the if condition which by the way has
(true|true&false). Referring to operator precedence true & false is false and true | false is true so it prints out pass.
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html
Page 470

nf.setMaximumFractionDigits(5);
System.out.println(nf.format(f1)+ " ");

it should be print rather than println as shown in the output. Nothing really BIG

Page 545
Table 7-2
Hashtable and not HashTable
Does any body how i could scan an entire html page and look for href and img tags and change some text in the tags.
15 years ago
I did modify the code now. There are three classes now The RemoteObjectPlayer is now a JPanel which contains the drawing canvas and also contains the label to display player moves. The jframe now takes as parameter a remote object player and adds it the contentpane. There is a third utility class that instantiates both of these classes and binds only the remoteobjectplayer. The thing is when a client registers with the server it passes a referrence to the server. But when server needs to call some methods back on the client to change the canvas display that doesnt work.

Well what i want is when the client connects to the server the server should have some mechanism of passing back some message or calling methods on the client side. so i made the client object also a remote object.

Is there some other alternative for server passing messages to client or calling methods on the client other than rmi.
15 years ago
There are no jframes on the server side. Actually there is no need of having any graphics on the server. Everything will be done on the client side.
15 years ago
This is the error i get when i run remoteobjectplayer.

java RemoteObjectPlayer
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.io.InvalidClassException: javax.swing.JFrame; local class incompati
ble: stream classdesc serialVersionUID = -2386951414768123374, local class seria
lVersionUID = -5208364155946320552
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:385
)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
66)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at RemoteObjectPlayer.main(RemoteObjectPlayer.java:63)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
ception is:
java.io.InvalidClassException: javax.swing.JFrame; local class incompati
ble: stream classdesc serialVersionUID = -2386951414768123374, local class seria
lVersionUID = -5208364155946320552
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:375
)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
66)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:707)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.InvalidClassException: javax.swing.JFrame; local class incomp
atible: stream classdesc serialVersionUID = -2386951414768123374, local class se
rialVersionUID = -5208364155946320552
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:546)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:155
2)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:155
2)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
699)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:19
08)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
... 9 more
15 years ago
Hi guys. In my remote object i am having a referrence to a jframe object. The thing is i am developing a game server. so when the one player makes the move then it is sent to server and server tells the other remote object to update its GUI.

So remote object is having referrence to the gui and when it receives the message it calls methods on the gui.

But i am getting a horrible error when i try to do this. This is code for the remoteobjectplayer



getting error message of marshalling and unmarshalling and that local jframe class something something. This must be some thing related to serialization. please let me know if you can figure this out.

Thanks
15 years ago