aspose 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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: 61608
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 61608
    
  67

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: 18978
    
  40

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: 61608
    
  67

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

Joined: Jul 26, 2007
Posts: 10519
    
    9

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

[How to ask questions] [Donate a pint, save a life!] [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://aspose.com/file-tools
 
subject: Main args given as input to a File