Java and xcode

F

FishStickBoy

Guest
I'm new to Java and xcode and I need some help.
I'm trying to make a server application and client application. I can do it on a pc but I was wondering how to do it in xcode. This is my client program:

import java.net.*;
import java.io.*;
public class Noland4 {
public static void main( String[] args ) {
if ( args.length < 1 ) {
System.err.println( "This does not work" );
return;
}

try {
System.out.println ("Please type a message: ");
BufferedReader input = new BufferedReader(new
InputStreamReader (System.in));
String s = input.readLine();
Socket sock = new Socket( args [0], 1234);
PrintWriter out = new PrintWriter( sock.getOutputStream() );
out.println( s);
out.flush();
BufferedReader in = new BufferedReader(
new InputStreamReader( sock.getInputStream() ) );
String t = in.readLine();
if ( t !=null )
System.out.println( "To server: "+ s +
"\nFrom server" + t );
sock.close();
} catch( IOException e ) {System.err.println( e ); }
}
}

When you run the code on a PC you enter in the command below, telling it to run the application and the IP address of the server. But when I run it in xcode I am not sure how to tell the application the IP address of the server to send or recieve anything.

c:java "name of the file" "ip address"
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top