File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Main args given as input to a File Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Main args given as input to a File" Watch "Main args given as input to a File" New topic
Author

Main args given as input to a File

vamsi acharya
Ranch Hand

Joined: Jun 28, 2009
Posts: 55

hey guys , am having some trouble with the following code snippet



I don't understand this code , the File should be given its path why is it so that it is given arguments of main method as input ? And also i am currently using NetBeans IDE, how to pass arguments of main method ?? Thanks in advance !


"Known is a drop , unknown is an ocean " !
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56175
    
  13

vamsi acharya wrote:File should be given its path why is it so that it is given arguments of main method as input ?

You pretty much answered your own question. The arguments passed to main are the paths to the files!

Also, you should always indent your code for readability.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
vamsi acharya
Ranch Hand

Joined: Jun 28, 2009
Posts: 55

Bear Bibeault wrote:
vamsi acharya wrote:File should be given its path why is it so that it is given arguments of main method as input ?

You pretty much answered your own question. The arguments passed to main are the paths to the files!

Also, you should always indent your code for readability.


Thanks mate but how to enter the main arguments in an IDE ??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56175
    
  13

I don't use eclipse, sorry.
vamsi acharya
Ranch Hand

Joined: Jun 28, 2009
Posts: 55

Bear Bibeault wrote:I don't use eclipse, sorry.


No problem hope anyone else can answer me that , can you please illustrate me how to enter path in main arguments in traditional way ??
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16684
    
  19

vamsi acharya wrote:
No problem hope anyone else can answer me that , can you please illustrate me how to enter path in main arguments in conventional way ??


It slightly different, depending on the version you are using, so take these instructions with a grain of salt.

Instead of just choosing the "run as" --> "application" option, choose "run configurations...". With some versions of eclipse, it may be named something slightly different. This should open a popup. Look for an "arguments" tab -- this should allow you to enter the command line arguments to give to the application.

[EDIT: it looks like from your first post, that you are using NetBeans, and not eclipse -- sorry, I don't use NetBeans]

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56175
    
  13

Oops, yeah, I don't use netbeans either.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8433

vamsi acharya wrote:
No problem hope anyone else can answer me that , can you please illustrate me how to enter path in main arguments in conventional way ??

By "conventional" I take it you mean the command line. For that you need to run your application like java MyApp /path/to/file

[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
vamsi acharya
Ranch Hand

Joined: Jun 28, 2009
Posts: 55

Maneesh Godbole wrote:
vamsi acharya wrote:
No problem hope anyone else can answer me that , can you please illustrate me how to enter path in main arguments in conventional way ??

By "conventional" I take it you mean the command line. For that you need to run your application like java MyApp /path/to/file


Now i get it , thanks mate !!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Main args given as input to a File
 
Similar Threads
Reg:Reading file with 100,0000 lines
Doubt on Generics
not able to read file which exists
Adding syntax highlighting to existing application.
Code compiles fine but stuck in the runtime