If you are wondering what program it's about, see this thread: http://www.antionline.com/showthread...hreadid=260759

I'm adding a feature to take a screenshot on a system and transfer the image to the computer were Crat (the client part) runs.

In Crat.java there is a class Connect (some formatting is lost):

Code:
class Connect {                           //class which is used for the connection. Only for txt streams
                                          //host (address) is hardcoded, this will change, it's just a detail
	
	Socket socket = null;
         InputStreamReader isr = null;
	BufferedReader reader = null;
	PrintWriter writer = null;
	String address = "192.168.1.3";
	int PORTNUM;
	
	public Connect(int port) {            //port is defined upon usage of constructor.
		PORTNUM = port;                   //Java VM 1.4.2-01-b6 hangs when also the host is defined in the contructor,
		                                  //works fine with newest 1.4.2 VM
    }
	
	void establishConnection() {          //void for establishing the connection and setting up I/O.
		
		try {
			socket = new Socket(address, PORTNUM);
			isr = new InputStreamReader(socket.getInputStream());
			reader = new BufferedReader(isr);
			writer = new PrintWriter(socket.getOutputStream(), true);
	    } catch (IOException e) {
	    	System.err.println("Exception: " + e.getMessage());
	    	System.exit(1);
	    }
    }
    
    void closeConnection() {              //void to close connection if needed
    	
    	try {
    	     reader.close();
    	     writer.close();
    	     socket.close();
        } catch (IOException e) {
        	         System.err.println("Exception: " + e.getMessage());
        	         System.exit(1);
        }
    }
}
which works fine and if you look at Crat.java you see that I have used it multiple times. But this class is not usable to transfer binary data (image) because of the InputStreamReader and PrintWriter which are only usable for all kinds of unicode text. Hence I created a new class (not on my website yet) that inherits from Connect:

Code:
class DataConnect extends Connect {     //class for transfer of image, inherits from Connect
	
	Socket socket = null;
	BufferedInputStream buffer = null;
	DataInputStream data_reader = null;
	
	public DataConnect(int port) {
	    PORTNUM = port;
         }
    
    void establishConnection() {
    	
    	try {
    		socket = new Socket(address, PORTNUM);
    		buffer = new BufferedInputStream(socket.getInputStream());
    		data_reader = new DataInputStream(buffer);
        } catch (IOException e) {
        	System.err.println("Exception: " + e.getMessage());
        	System.exit(1);
        }
    }
}
It might use Connect's methods so it inherits from it.
Upon compiling Crat.java with this class added this error occurs:

Crat.java:140: Connect(int) in Connect cannot be applied to ()
public DataConnect(int port) {

Although I have been coding Java for a few years I never really had the need to use inheritance. Anybody knows what I'm doing wrong? I know I can simply add DataConnect's functionnality to Connect and it is solved but I would like to do it this way.