Hey guys. Been lurking the forums for some time, and as a non-programmer am teaching myself Java out of curiosity and (at least potentially) career thoughts if I like it. Been at it in my spare time for about two months now, finished Head First Java, about 1/3rd of the Sun Java Tutorial, and am waiting on Thinking in Java 4th Ed to arrive at my library. So in short, I am new, I suck, but I appreciate any assistance, and have loved browsing the forum.
At work I am constantly having to disconnect & reconnect my VPN client. Even though a Windows shortcut would do the same thing, out of practice I am trying to build a basic GUI that gives me buttons & hotkeys to connect/disconnect it more easily.
The command line to launch the VPN client & connect is:
"C:\Program Files\AT&T Global Network Client\NetClient.exe -connect -login=password"
Typing this in either the Windows XP Run box, or on the command line, starts up the client and connects to the network.
Unfortunately, I can't get my Java program to do the same thing, and am pulling my hair out.
Here is my code:
This launches my VPN client window, but does not connect it. I have tried a couple variations:
And each time my VPN client launches but does not connect, despite the same lines appearing to work in the Run box.
Am I formatting the command line arguments incorrectly in my code somehow? Is my VPN Client somehow knowing this is machine generated code and not allowing it to connect? Or am I just doing something dense?
A single monolithic command line has to get broken up into arguments somewhere. On Windows, it's actually up to the individual program to do that -- usually it's the "C" runtime library that does it. Because of this, command-line parsing on Windows is quirky and sometimes painful. Every program can do it differently!
On a real operating system (UNIX-alike) it's the shell that does this; that way it's done uniformly for all programs, and it's a lot more predicatable.