Feb 5, 2003 #1 25884 Programmer Mar 12, 2001 46 AP Hi All, Is there a way to pass a parameter when i run a .exe file? I want to pass in a file name. Thanks, Sonali.
Hi All, Is there a way to pass a parameter when i run a .exe file? I want to pass in a file name. Thanks, Sonali.
Feb 5, 2003 #2 Rayz66 Programmer Sep 3, 2002 30 GB Yep, the class that gets run has a method called main: Code: public static void main(String[] args) { // do stuff } The args array contains the parameters typed in when the class was invoked: java myprog myfile.txt So args[0] will contain 'myfile.txt' ... not quite sure what you mean by the .exe though; Java executables are suffixed with .class Upvote 0 Downvote
Yep, the class that gets run has a method called main: Code: public static void main(String[] args) { // do stuff } The args array contains the parameters typed in when the class was invoked: java myprog myfile.txt So args[0] will contain 'myfile.txt' ... not quite sure what you mean by the .exe though; Java executables are suffixed with .class