1

I seem to be following instructions in the book I'm using as well as in Oracle's Java SE docs but cannot overcome the following error:

Error: Could not find or load main class com.practicalJava.lesson25.StartServer

I'm using the following command line on my Windows 7 box:

[C:\>]java -classpath /Practical_Java/Lesson25/bin -Djava.rmi.server.codebase=file:/Practical_Java/Lesson25/bin/ com.practicalJava.lesson25.StartServer

From the docs:

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

where classDir is the root directory of the class file tree

My compiled by Eclipse classes are in package com.practicalJava.lesson25.

My bin directory is located at

C:\Practical_Java\Lesson25\

My StartServer.class file is located at:

C:\Practical_Java\Lesson25\bin\com\practicalJava\lesson25

I'm obviously doing something wrong. But what???

* UPDATE: *

Typo: StartSever instead of StartServer

PM 77-1
  • 12,933
  • 21
  • 68
  • 111
  • I would use an IDE, it is faster to develop and debug in and it will setup your class path correctly. – Peter Lawrey Apr 21 '13 at 21:23
  • I'm using `Eclipse`, but I need to launch all the three `RMI` components (registry, server, and client) in different JVMs. – PM 77-1 Apr 21 '13 at 21:32
  • You can run three different JVMs from eclipse. – Peter Lawrey Apr 21 '13 at 21:54
  • This question has nothing to do with RMI or the codebase feature. It is just a misuse of the command line. There is no such thing as 'bin' directory for Java programs. Your .class file is simply in the wrong place in the file system. – user207421 Apr 21 '13 at 22:27
  • @EJP - It's exactly where Eclipse put it. For Eclipse project structure (not Java in general) `bin` plays its role. – PM 77-1 Apr 21 '13 at 22:30
  • Then Eclipse has put it in the wrong place. It should be in a directory hierarchy corresponding to the package hierarchy. The *head* of that hierarchy is the CLASSPATH. – user207421 Apr 21 '13 at 22:33
  • get sure you start the console with admin rights. – Simulant Apr 21 '13 at 22:35
  • Yes, I have admin rights and I included package information into my post. – PM 77-1 Apr 21 '13 at 22:39
  • @EJP - Yes, you're right this is some kind `CLASSPATH` issue. I'm still at loss where I made a typo or other stupid mistake. – PM 77-1 Aug 08 '13 at 20:24

1 Answers1

0

Write Command for start the Server :

rmic HelloServer

start rmiregistry

Write Command for start the Client :

java -cp "C:\Program Files (x86)\apache-tomcat-7.0.16\webapps\ROOT\RMI\RMI" -Djava.rmi.server.codebase=file:/RMI/ -Djava.security.policy=Client.policy HelloClient

=================================

If you are using manaully deploy in the Tomcat folder then you should set the environment variable of classpath="C:\Program Files (x86)\apache-tomcat-7.0.16\webapps\ROOT\RMI\RMI" Upto RMI folder where you put the code....

This is really working....

Community
  • 1
  • 1
Vishal Shah
  • 641
  • 6
  • 17
  • Thank you for the contribution. Unfortunately it does not seem to have anything to do with my question. – PM 77-1 Apr 24 '13 at 17:49