Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to load class dynamically from another location In RMI

 
dashang trivedi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FIRST I START WEB SERVER in (download directory) first window
1) ---> java NanoHTTPD 8080


then i start rmi registry ( second window)(RMIDIR Directory)
2) ---->RMIREGISTRY

then i start Server (Third window) (Server Directory)
3) ---->java -Djava.rmi.server.codebase=http://localhost:8080/ CalcServer
In serever directory

three file
calc.java(interface)
calcimpl.java
calcserver.java


4)In client directory......
javac -cp (path of server ) CalcClient.java
AND Run
java CalcClient



it will give Exception class not found.....
If i manually copy Calc.class file in client directory....then program success fully run...........
so any body know HOW THE DYNAMIC DOWNLOADING is done.......
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Dashang!

Champion, I myself have never done this, but it looks like it is not complicated. Please take a look at Dynamic code downloading using RMI tutorial, which I think might be helpful.

Another tip I'd like to ask you, whenever you post code, please post it between the Code tags. It makes the post more readable!

You can edit your post to include these tags by clicking on the button.
 
dashang trivedi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir....thank you for reply.......
i have already...seen rmi dynamic class loading.............


but i am not finding the solution, .......please tell me how to do..........
 
Abhijeet Nalawade
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dashang,

Can you let me know the contents fetched from location http://localhost:8080/ CalcServer.

3) ---->java -Djava.rmi.server.codebase=http://localhost:8080/ CalcServer

The codebase property should return the jars/classes files which are downloaded to client system on remote object lookup.

 
dashang trivedi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CalcServer.java file..........

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The posted code shows:



But the server was started as:


So which is it - default port 80 or changed port 8080

Bill
 
dashang trivedi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for RMI i need A WEB SERVER .......
so web server(java NanoHTTPD 8080 ) is started on 8080 port.......

Now from server machine codebase pass to WEBSERVER.....and it will BIND TO RMI REGISTRY.......

So my port is 8080.........

 
Abhijeet Nalawade
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dashang,

Can you implement small modification to class CalcSever

//Code to Replace

//New Code

I tried the same locally it worked, hope the same is the case with you too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic