Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi All, Is there a way to pass a p

Status
Not open for further replies.

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.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top