Re: Complete command arguments



[short]
Is it possible, in a Java program, to get the complete command
string that was used to start that program?

Thats really quite easy, a mere "enhanced for loop" does the job quite nicely:

public static void main(String[] args) {
StringBuffer arguments = new StringBuffer();
for (String a : args) {
arguments.append(a + " ");
}
}

The only possible downside to this idea is the space at the end, but thats
something a mere trim() can fix.

..in response to the user configuring certain aspects of the program that
are difficult to clean up and re-initialise. So.. if there was some other
way to get a Java program to restart itself, that would do too (though my
searching so far suggests there isn't[?]).

Depending on the context I can't help wonder if you should check if your design
could use adjusting. It sounds a bit odd that the only way to accomplish new
settings is to start the entire program like this. But thats hard to comment on
considering the fact that this heavily depends on context.


--
..\\ PGP/GPG key: http://www.catslair.org/pubkey.asc

.



Relevant Pages

  • Re: call of ShellExecuteEx causes error message
    ... My Java program brings up its own window and is for drawing curves, ... //define pix vector from Photoshop image ... //make string from pix vector ... the call of ShellExecuteEx worked. ...
    (microsoft.public.win32.programmer.networks)
  • Re: call of ShellExecuteEx causes error message
    ... My Java program brings up its own window and is for drawing curves, ... //define pix vector from Photoshop image ... //make string from pix vector ... the call of ShellExecuteEx worked. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Current Class Path
    ... | Could anyone tell me how to get the class path and not the jdk path? ... * Returns a string consisting of the current working directory. ...
    (comp.lang.java.programmer)
  • Re: string change in jsp
    ... Which platform do you use for development? ... in Java program or JSP please use its unicode rather than ... using ASCII or ISO-8859-1 ... but when i am passing this string in querystring its not taking the ...
    (comp.lang.java.programmer)