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

[B]javac[/B] -d [U]destDir[/U] Hello.java Server.java Client.java

I use...

[B]C:\"Program Files"\Java\jdk1.6.0_11\bin\javac [/B] -d [U]C:\"Documents and Settings"\"Andrew  Carrara"\Desktop\test\mysrc\example.hello[/U] 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..

[B]start java[/B] -classpath [U]classDir[/U] -Djava.rmi.server.codebase=file:classDir/ example.hello.Server

I am doing ...

[B]C:\"Program Files"\Java\jdk1.6.0_11\bin\start java[/B] -classpath [U]C:\"Documents and Settings"\myname\Desktop\test\mysrc\example.hello[/U] 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.

Recommended Answers

All 11 Replies

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.

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.

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.

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

how do i reference the root folder?

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

So in my case ...

C:\"Documents and Settings"\myname\Desktop\test\[B]mysrc[/B]\[U]example.hello [/U]

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.

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...

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.

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...

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.