954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

RMI Client Server

So I am going through the "Getting Started Using Java RMI" and I get stuck at the following spot...

<strong>javac</strong> -d destDir Hello.java Server.java Client.java


I use...

<strong>C:\"Program Files"\Java\jdk1.6.0_11\bin\javac </strong> -d C:\"Documents and Settings"\"Andrew  Carrara"\Desktop\test\mysrc\example.hello Hello.java Server.java Client.java

I get an invalid flag error.


What exactly does the '-d' do, and what should happen in the destDir?

the Directory I am using is ...

C:\"Documents and Settings"\myname\Desktop\test\mysrc\example.hello

This is where the .class files are already located.

I am able to run the RMIRegistry with no problem.

Further down I get stuck at Start the server

They say to do this..

<strong>start java</strong> -classpath classDir -Djava.rmi.server.codebase=file:classDir/ example.hello.Server


I am doing ...

<strong>C:\"Program Files"\Java\jdk1.6.0_11\bin\start java</strong> -classpath C:\"Documents and Settings"\myname\Desktop\test\mysrc\example.hello example.hello.Server


I know the next below stuff is annoying to add the path of my compiler but that is how I got it working for now. I will fix this later when i have more time to spare.

C:\"Program Files"\Java\jdk1.6.0_11\bin\java

Can some one help me figure how to connect the hello world client server example? May be point out what I am doing wrong.

Thank you for your patience and guidance.

I need to connect this so I can apply other code to this process, to make requests from the client to the server.

transplantedNYr
Junior Poster in Training
51 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

Alright I tried just running it in the directory with all the -d and class directory just with java Client localhost and server, but server first, and RMI is already running.

This gave me a RemoteException and a class not found error.

Going back to keep trying.

transplantedNYr
Junior Poster in Training
51 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

all -d should do, is put the compiled classed in your specified directory. i am not exactly sure what you are having issues with, if you can be more specific, perhaps we can be of more help.

a classnotfound will be the result of the specific class missing from your classpath.

sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
 

That is what I thought. I just compiled and have the class files in the same file where they are currently located.

I guess I need help with the connecting to "Server" and connetcing to the "Client".

Am using the class directory correctly? I am using the location of the class files.

transplantedNYr
Junior Poster in Training
51 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

yes, the class directory is the correct classpath, but if they are in packages, make sure you reference the root folder.

sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
 

how do i reference the root folder?

transplantedNYr
Junior Poster in Training
51 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

if you have packages e.g. "com.myproject.main", it will be represented through a file struction /com/myproject/main, the classpath is not [directory]/com/myproject/main, but it is simply [directory].

[directory] - is the parent folder of "com". hopefully that makes sense

sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
 

So in my case ...

C:\"Documents and Settings"\myname\Desktop\test\<strong>mysrc</strong>\example.hello


The class files are in "example.hello" folder.

So my source directory (classpath) would be? mysrc? or example.home?

Would this be the case?

If there was no package, would the source directory (classpath) be?

Thanks again.

transplantedNYr
Junior Poster in Training
51 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

if you use the default package (i.e. no package), you simply reference the folder containing all your class files. i am curious how you came up with the folder name example.hello, because it seems to resemble a package...

sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
 

I came up with example.hello through the "Getting Started Using Java RMI" from Sun / java site.

Yes, it is the package included on these files.

transplantedNYr
Junior Poster in Training
51 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

do you understand what packages are?

a package of example.hello, does not mean having a folder called example.hello. if you want a file structure to represent example.hello, you need example/hello...

sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
 

The problem was I did not have my CLASSPATH set up.

Got it to work.

My schools tutor's walked me through the process. 2 hours later...

Thanks for your help.

transplantedNYr
Junior Poster in Training
51 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You