jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes how XML files passing to main class... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how XML files passing to main class..." Watch "how XML files passing to main class..." New topic

how XML files passing to main class...

vinaykumar singh

Joined: Jan 14, 2006
Posts: 13
hello all...

i m using eclipse.i want to pass xml files(more than 3)as a main method argument. how it is done.

please help me ....
vinay kumar singh
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You can pass the paths to the three files as command line arguments, read them in your main method then load the XML files. e.g.:

(Please note the above code is deliberately simplistic - you'll have to write the Handler, and think about what you do with regards to Exception handling and validation)
[ January 30, 2006: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
To actually run Paul's example from the command line, you would type

I don't know how Eclipse handles command-line arguments. You should search through the project options to see if you can figure out how to set them. If you don't find anything, ask your question in the IDE forum.


p.s. You might also want to modify Paul's example to take any number of command-line arguments. This way the user can specify 1 or 500, if they wish. Of course, this depends on whether or not this type of usage is meaningful for your program.
[ January 30, 2006: Message edited by: Layne Lund ]

Java API Documentation
The Java Tutorial
Raveendra Kumar

Joined: Dec 20, 2005
Posts: 12
In the run window, there is Arguments tab. Here you can type whatever arguments you want to send to your program.
Hope this works out for you.
I agree. Here's the link: http://aspose.com/file-tools
subject: how XML files passing to main class...
It's not a secret anymore!