Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #21 (permalink)  
Old 04-22-2008, 03:43 PM
Member
 
Join Date: Apr 2008
Posts: 91
javarishi is on a distinguished road
Hei Buddy, This Code You Need To Put Inside The Class.

If you are a buiginner in java i suggest for Cathey Sierra HeadFirst java Book. Please Go Through It First.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #22 (permalink)  
Old 04-22-2008, 03:44 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
Quote:
Originally Posted by denisdoherty View Post
When i put public void ReturnAverage (String Average) throws RemoteException
{
}
You need to put this code in implementing class dear.

If still you have doubt ..please post your interface and class code.


sanjeev

Bookmark Post in Technorati
Reply With Quote
  #23 (permalink)  
Old 04-22-2008, 03:55 PM
Member
 
Join Date: Apr 2008
Posts: 91
javarishi is on a distinguished road
Hei denisdoherty,
Are You Done With The Problem? Any Help Required ?
Bookmark Post in Technorati
Reply With Quote
  #24 (permalink)  
Old 04-22-2008, 04:02 PM
Member
 
Join Date: Apr 2008
Posts: 31
denisdoherty is on a distinguished road
I still cannot get the { error part. Do u want me to post the code inside the interface and the code in the class?
Bookmark Post in Technorati
Reply With Quote
  #25 (permalink)  
Old 04-22-2008, 04:04 PM
Member
 
Join Date: Apr 2008
Posts: 91
javarishi is on a distinguished road
Yaah you paste it here.
Bookmark Post in Technorati
Reply With Quote
  #26 (permalink)  
Old 04-22-2008, 04:12 PM
Member
 
Join Date: Apr 2008
Posts: 31
denisdoherty is on a distinguished road
The code that i have in the interface is.

The first error that I am getting is highlighted in bold.

The error hear is Interface methods cannot have body.

Code:
import java.rmi.Remote; import java.rmi.RemoteException; interface Interface extends Remote{ //Returns the Sum of the Number public void ReturnSum (String Sum) throws RemoteException { } //Returns the Product of the Number public void ReturnProduct (String Product) throws RemoteException { } //Returns the Average of the Number public void ReturnAverage (String Average) throws RemoteException { } }//end Interface
And the code that i have in the class is.

The error that i am getting within this class is highlighted in bold.

This error is Helper is not abstract and does not override abstract method ReturnAverage(java.lang.String) in Interface

Code:
import java.net.*; import java.io.*; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; import java.rmi.registry.LocateRegistry; import java.rmi.RMISecurityManager; public class Helper implements Interface { private final int SIZE =10; private ASumList sumList[]; private int serverPort; private int numNumber; private InetAddress serverHost; private StreamSocket mySocket; // private InetAddress serverHost; public Helper(){ super(); sumList = new ASumList [SIZE]; numNumber = 0; } Helper(String hostName,String portNum) throws SocketException, UnknownHostException, IOException { this.serverHost = InetAddress.getByName(hostName); this.serverPort = Integer.parseInt(portNum); //Instantiates a stream-mode socket and wait for a connection. this.mySocket = new StreamSocket(this.serverHost, this.serverPort); System.out.println("Connection request made"); } // end constructor public String getnumber( String message) throws SocketException, IOException{ String number = "", nextnumber="";; mySocket.sendMessage( message); // now receive the names nextnumber = mySocket.receiveMessage(); while (!nextnumber.equals("")) { number += nextnumber+" "; nextnumber = mySocket.receiveMessage(); } return number; } // end getnumber public synchronized int ReturnSum (){ String list =""; for (int i = 0; i < numNumber; i++) list = list+ sumList[i].getSum(); list.trim(); return numNumber; } public synchronized int Returnproduct(){ String list =""; for (int i =0;i<numNumber; i++) list = list+sumList[i].getSum(); list.trim(); return numNumber; } public synchronized int ReturnAverage(){ String list =""; for (int i = 0; i<numNumber; i++) list = list+sumList[i].getSum(); list.trim(); return numNumber; } public void done( ) throws SocketException, IOException{ mySocket.close( ); } // end done } //end class
Would be greatful if anyone can help.

Thanks
Bookmark Post in Technorati
Reply With Quote
  #27 (permalink)  
Old 04-22-2008, 04:20 PM
Member
 
Join Date: Apr 2008
Posts: 91
javarishi is on a distinguished road
I have made the necessary changes. Try To Compile It.

Interface
----------

import java.rmi.Remote;
import java.rmi.RemoteException;

interface Interface extends Remote{

//Returns the Sum of the Number
public void ReturnSum (String Sum) throws RemoteException;

//Returns the Product of the Number
public void ReturnProduct (String Product) throws RemoteException;

//Returns the Average of the Number
public void ReturnAverage (String Average) throws RemoteException;
}//end Interface


Class
--------

import java.net.*;
import java.io.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.registry.LocateRegistry;
import java.rmi.RMISecurityManager;

public class Helper implements Interface {

private final int SIZE =10;
private ASumList sumList[];
private int serverPort;
private int numNumber;
private InetAddress serverHost;
private StreamSocket mySocket;
// private InetAddress serverHost;

public Helper(){
super();

sumList = new ASumList [SIZE];
numNumber = 0;
}

Helper(String hostName,String portNum) throws SocketException,
UnknownHostException, IOException {
this.serverHost = InetAddress.getByName(hostName);
this.serverPort = Integer.parseInt(portNum);
//Instantiates a stream-mode socket and wait for a connection.
this.mySocket = new StreamSocket(this.serverHost, this.serverPort);
System.out.println("Connection request made");

} // end constructor


public String getnumber( String message) throws SocketException, IOException{
String number = "", nextnumber="";;
mySocket.sendMessage( message);

// now receive the names
nextnumber = mySocket.receiveMessage();
while (!nextnumber.equals("")) {
number += nextnumber+" ";
nextnumber = mySocket.receiveMessage();
}
return number;
} // end getnumber


public synchronized int ReturnSum (){
String list ="";
for (int i = 0; i < numNumber; i++)
list = list+ sumList[i].getSum();
list.trim();
return numNumber;
}
public synchronized int Returnproduct(){
String list ="";
for (int i =0;i<numNumber; i++)
list = list+sumList[i].getSum();
list.trim();
return numNumber;
}

public synchronized int ReturnAverage(){
String list ="";
for (int i = 0; i<numNumber; i++)
list = list+sumList[i].getSum();
list.trim();
return numNumber;
}
public void done( ) throws SocketException, IOException{
mySocket.close( );
} // end done

//Returns the Sum of the Number
public void ReturnSum (String Sum) throws RemoteException
{
}
//Returns the Product of the Number
public void ReturnProduct (String Product) throws RemoteException
{
}
//Returns the Average of the Number
public void ReturnAverage (String Average) throws RemoteException
{
}
} //end class

Any Further Queries, let me know.
Bookmark Post in Technorati
Reply With Quote
  #28 (permalink)  
Old 04-22-2008, 04:23 PM
Member
 
Join Date: Apr 2008
Posts: 31
denisdoherty is on a distinguished road
that has compiled now thanks very much.
Bookmark Post in Technorati
Reply With Quote
  #29 (permalink)  
Old 04-22-2008, 04:25 PM
Member
 
Join Date: Apr 2008
Posts: 91
javarishi is on a distinguished road
Ok Good. Always welcome for good Questions. We all should learn and

improve. Try to read the book which i have suggested.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 08:38 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org