• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Main args given as input to a File

 
Ranch Hand
Posts: 55
Android Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !
 
Sheriff
Posts: 67695
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
vamsi acharya
Ranch Hand
Posts: 55
Android Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67695
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't use eclipse, sorry.
 
vamsi acharya
Ranch Hand
Posts: 55
Android Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ??
 
author
Posts: 23931
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Bear Bibeault
Sheriff
Posts: 67695
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, yeah, I don't use netbeans either.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
vamsi acharya
Ranch Hand
Posts: 55
Android Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 !!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic