aspose file tools*
The moose likes Java in General and the fly likes Problem in using rmic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem in using rmic" Watch "Problem in using rmic" New topic
Author

Problem in using rmic

Radha MahaLakshmi
Ranch Hand

Joined: Mar 28, 2003
Posts: 45
Hi All
I am trying a simple RMI application.I created a package like example.hello and under this i had written Hello.java,HelloImpl.java,HelloClient.java
I compiled all these classes.
I am trying to rmic to generate skeliton and stub classes.
i have c:\ as my current directory and i am using the following command
C:\>rmic -classpath c:\examples\hello\ HelloImpl
its giving the following error
error: File c:\examples\hello\HelloImpl.class does not contain type HelloImpl as
expected, but type examples.hello.HelloImpl. Please remove the file, or make su
re it appears in the correct subdirectory of the class path.
error: Class HelloImpl not found.
2 errors
Please suggest me how to go.
Regards
Radha
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi again,
The answer to this question is pretty much the same as my answer to your last question, a short time ago: you're telling rmic to compile a class "HelloImpl" when in fact you want it to compile examples.rmic.HelloImpl.
Again, the answer: don't set the classpath or use the classpath switch. From c:\ just type "rmic examples.hello.HelloImpl" .


[Jess in Action][AskingGoodQuestions]
Radha MahaLakshmi
Ranch Hand

Joined: Mar 28, 2003
Posts: 45
Hi
i tried compiling from c:\
as rmic examples.hello.HelloImpl
its giving the following error
C:\>rmic examples.hello.HelloImpl
error: Class examples.hello.HelloImpl not found.
1 error
Regards
Radha
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, you've probably still got the CLASSPATH variable set from the last time -- you need to unset it, or at least make sure it includes ".", the current directory, and does not include examples/hello.
Of course, I'm assuming that examples/hello/HelloImpl.class exists, because you compiled it before.
Radha MahaLakshmi
Ranch Hand

Joined: Mar 28, 2003
Posts: 45
Hi Ernest
Sorry.my classpath does not include ".".
Now i am able to compile it.
i am new to this RMI.Can you please let me know how to go form here.
i started rmi registry.
then i tried to run HelloImpl but its giving the following erro.
Can ypu please let me know any good tutorial avilable.
HelloImpl err: access denied (java.net.SocketPermission myhost resolve)
java.security.AccessControlException: access denied (java.net.SocketPermission m
yhost resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at examples.hello.HelloImpl.main(HelloImpl.java:29)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

The tutorial at http://java.sun.com/docs/books/tutorial/rmi/index.html is perfectly nice. You're pretty much all the way there except for the necessary security policy stuff, which is covered under the last page of this tutorial "Running the Example Programs." What you'll need to do is create a java.policy file, as directed, and install it properly.
A shortcut (note that you shouldn't do this in production, but if you just want to get things running quickly, and then go back and deal with security later!) is to comment out the lines that set the RMISecturityManager. If you were to comment out those two lines, recompile and re-rmic your classes, you'd find that your program should work fine!
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'm moving this fancy talk to The Intermediate Forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in using rmic