• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

head first rmi error

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all..copied the head first code examples rmi but get this error ..can anyone help..single on home desktop computer on loop back...


java.net.MalformedURLException: invalid URL String: Remote Hello
at java.rmi.Naming.parseURL(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at MyRemoteImp1.main(MyRemoteImp1.java:44)
Caused by: java.net.URISyntaxException: Illegal character in path at index 6: Remote Hello
at java.net.URI$Parser.fail(Unknown Source)
at java.net.URI$Parser.checkChars(Unknown Source)
at java.net.URI$Parser.parseHierarchical(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.<init>(Unknown Source)
at java.rmi.Naming.intParseURL(Unknown Source)
... 3 more

import java.rmi.*;
public interface MyRemote extends Remote
{
public String sayHello() throws RemoteException;
}
import java.rmi.*;
import java.rmi.server.*;

public class MyRemoteImp1 extends UnicastRemoteObject implements MyRemote
{
public String sayHello()
{
return "Server says, 'Hey'";
}
public MyRemoteImp1() throws RemoteException
{

}

public static void main(String[]args)
{
try
{
MyRemote service = new MyRemoteImp1();
Naming.rebind("Remote Hello",service);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
import java.rmi.*;
public class MyRemoteClient
{
public static void main(String[]args)
{
new MyRemoteClient().go();
}
public void go()
{
try
{
MyRemote service = (MyRemote)Naming.lookup("rmi://127.0.0.1/Remote Hello");
String s =service.sayHello();
System.out.println(s);
}
catch(Exception ex){ex.printStackTrace();}


}
}
thank you
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi kieran,

I can't test this at the moment but from the exception you get when trying to run this application I guess the problem is simply the space character between "Remote" and "Hello". I guess you should strip this space out or correctly encode the URL like other URLs (for example HTTP URLs).

I hope this helps...

Marco
 
kieran pattni
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you...not sure if it is mistake in the book but its working now..thanks
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok�, my problem is not the same as the original post but my exercice is. When I run my batch file (%rmic MyRemoteImpl) my command prompt goes haywire, it just keeps giving me the line "--location-->rmic MyRemoteImpl" endlessly. Does anyone have any ideas on what I'm doing wrong?
 
I found some pretty shells, some sea glass and this lovely tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic