PDA

View Full Version : [SOLVED] make a java program start with arguments?



Griff
April 3rd, 2008, 09:40 PM
I'm working on writing a server/client program and I'd like to be able to set the ip address that the client needs to connect to by passing in as an argument.
For example:

RegisterClient 192.168.1.50
As opposed to hardcoding the address in the client and having to recompile.

Thanks,
Griff

smartbei
April 3rd, 2008, 09:43 PM
You may want to check this out: http://java.sun.com/docs/books/tutorial/essential/environment/cmdLineArgs.html

CptPicard
April 3rd, 2008, 09:44 PM
public static void main(String[] args) {
String myArg = args[0];
}

Griff
April 3rd, 2008, 10:14 PM
Well I thought it would be a little more difficult than that. I feel like I wasted your time! :)
Thanks!
-Griff