permaculture playing cards*
The moose likes Distributed Java and the fly likes how to load class dynamically from another location In RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "how to load class dynamically from another location In RMI" Watch "how to load class dynamically from another location In RMI" New topic
Author

how to load class dynamically from another location In RMI

dashang trivedi
Greenhorn

Joined: Mar 01, 2010
Posts: 26
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

Joined: Dec 28, 2007
Posts: 2258
    
    3

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.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
dashang trivedi
Greenhorn

Joined: Mar 01, 2010
Posts: 26
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

Joined: Apr 01, 2007
Posts: 20
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

Joined: Mar 01, 2010
Posts: 26
CalcServer.java file..........

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12755
    
    5
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

Joined: Mar 01, 2010
Posts: 26
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

Joined: Apr 01, 2007
Posts: 20
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to load class dynamically from another location In RMI
 
Similar Threads
in rmi Its necessary to manually copy a Class file for remote interface in client directory?
want to integrate RMI with application on Client machine
RMI Newbie
Dynamic loading of class in RMI
Dynamic Loading Class in RMI