About command line arguement

I want to take in a list a of words from a file as a command line argument, like the following input to the command line:
hello
hi
cat
dog
fish
how this should be done?I only know I could use a single line when specifing command line argument,how can I use multiple lines?
thanks.

A command line is only a single line. You specify it
when program execution is started:
java TestProgram arg1 arg2 ...
If you want to specify multiple lines of data then
this becomes program input and you must create you own
input loop in your program. Something like:
BufferedReader input = new BufferedReader( System.in
String line = "";
while ( (line = in.readLine() ) != null )
System.out.println( line );
Or create a small simple class that reads the file but into an array instead of a single line, and call the main method of your class with that array.
//Håkan

Similar Messages

  • Starting an application using command line arguements

    Hi All,
    I need to launch an application by passing command line arguements. How to go about it?
    Thanks
    Sakthi

    is this an application you've written, or one you've downloaded? the two ways I know of to run an app from the command line are to use the 'open' command (e.g. +open -a appName+), or to run the exectuable element directly (usually something like /path/to/appName.app/Contents/MacOS/appName). the open command doesn't have an option for passing parameters; running the executable directly will allow you to pass parameters unix-style (assuming the executable is designed to accept them), but doesn't always run the application the same way as double-clicking on the file.
    you can also try applescript (from the command line use osascript) if the app is scriptable.

  • Newby question about command line interface

    Arch is my first linux distro and havnt used others yet.
    Just wondering, does Command Line Interface looks and functions all same on other distros?
    Because, if u can chose desktop environment like KDE, GNOME and Xfce with other Linux distros as well, then what is difference between others.
    Linux is still quite hard for me and just wanted to know if there is "special" stuff that arch can do.
    To me, they all looks same with same desktop environment...
    thanks

    When you mention the "command line interface" (CLI) there are a few things involved: a terminal emulator, a shell, and the programs you have installed. That said, as far as running programs goes
    The terminal emulator is the application that hosts/shows your shell. In KDE it's (by default) Konsole, GNOME uses gnome-terminal, others might use xterm, aterm, rxvt, rxvt-unicode or one of many others. Different emulators provide some extra features (e.g. tabs) and they all differ in memory usage, speed, and integration (or not) into a given desktop environment. That said, they all pretty much work the same for launching programs and operating in a shell: you type commands and press enter.
    The shell is what runs your commands and also provides some scripting capabilities. Generally, bash seems to be the most used as a default shell. You can change your shell if you wish, as some shells provide extra features like programmable command completion. Other shells are lighter or more POSIX-compliant. For a starting user, you're well enough off just using the default (probably bash) until you find a reason for which you must have a different shell.
    Finally, the programs installed will affect what you can run in a terminal. Different distros will have different quantities of programs installed by default. (Arch's base install is very minimal.)
    Now, with regards to Linux, at the end of the day all distros are Linux with some desktop environment (DE) and some Linux apps. The DEs and applications are taken from the same source, but some distros provide patches for extra capabilities or configuation. However, if you see something you like in openSUSE, say, you can download the software, patch it, and configure your Arch to work like openSUSE. Each distro, though, has its own focus and philosophy which affects:
    * how many and what applications are installed by default
    * amount of configuration required after install
    * stable vs. bleeding edge
    You can read more about this in the wiki reference above.
    So having said all that, Arch gives you a simple, minimal base install which you can then easily customize by app installation and configuration. It is reasonably bleeding edge, meaning application updates usually make it to Arch fairly quickly. With time and knowledge you can make Arch do near anything that another distro can do, but that's not really the idea behind Arch in my opinion.
    Hope that helps,
    j

  • Calling main method in another class using command line arguements

    Hi
    My program need to use 4 strings command line arguments
    entered in Project properties/Run/Application Parameters
    java programming for beginners // arguments
    The program needs to call main in the second class 4 times using argument 1 the first call, argument 2 the second call on so on.
    So the output wil be
    java
    programming
    for
    beginners
    import java.lang.*;
    public class First extends Second{
      public static void main(String[] args) {
        for(int i = 0; i < args.length; i++){
           Second.main(args); // Error I think
    import java.lang.*;
    public class Second {
    public static void main(String[] args){
    System.out.println(args[0]);
    "First.java": Error #: 300 : method main(java.lang.String) not found in class Second at line 6, column 15
    I am only a beginner with little knowledge of java so can the code be as basic as possible

    Your style looks quite bad for starters..... Hows
    this://import java.lang.*; /* NOT NEEDED */
    public class First extends Second{
    public First(String s) {
    super(s);
    public static void main(String[] args) {
    for(int i = 0; i < args.length; i++){
    new First(s);
    public class Second {
    public Second(String s)
    System.out.println(s);
    NOT NEEDED:
    public static void main(String[] args){
    System.out.println(args[0]);
    }My question to you: Do you understand why my code
    works? (does it do what you want?)I think since this is some kind of lesson, the OP have to implement some way to use the main method of the Second class as it is, that is, with String[] args. I think this lesson is interesting exactly because of this requirenment. But, anyway, I don�t know, that is just my assumption...

  • About Command line args

    there is command line argument fir integer like Integer.parseInt(args[0]); can we write same for "char" and" double" also like "Double.parseDouble" or else......

    this has nothing to do with command line arguments
    but yes, all the primitive wrapper classes can parse back their primitive
    Learn to use the API, it's your friend
    http://java.sun.com/javase/6/docs/api/

  • Confused about command line syntax

    Why does (at the command prompt)
    java com.sisconet.mpeapi.MpeApiwork properly, and
    java -D . -classpath . com.sisconet.mpeapi.MpeApireturn the error:
    Exception in thread "main" java.lang.NoClassDefFoundError: /I would think they would basically be equivalent, in fact, I thought I needed "-classpath ." to make it work. There is almost nothing in MpeApi.java, just a test file with some println statements.
    Thanks!

    java -D . -classpath . com.sisconet.mpeapi.MpeApiThis means: run the class called "." and pass it the parameters "-classpath . com.sisconet.mpeapi.MpeApi"Since there is no class called "." you get a NoClassDefFoundError.
    What is the "-D" supposed to do?

  • Does anyone know about command line printing?

    I have been trying to get my company's point of sale system moved from an old windows machine to a mac mini server. I have been successful with the exception of printing. Basically, as I understand it, the database we use sends a print command to the printer like lp -d "printer name". The problem is the HP laser printer receives it and flashes the orange light instead of printing. To get it to print we must push the green button on top of the printer to get it to print. When it prints everything is fine. I have two HP laser printers that do not have this problem and work correctly. They are Laser Jet P4015 and a M1212nf. The ones that don't work correctly are Laserjet P1505n, P2055, & P1022n. They are all network printers and work fine for regular printing like a word doc or web page. Any help is appreciated.
    Also, I have some impact printers both 9pin & 24pin that seem to be almost impossible to configure with OSX.  Any tips there would be great as well. 
    Thanks.

    Any thoughts on what to look for?
    The basic problem as I see it is that all the laser printers with which I am familiar do not cope with printing anything other than a page at a time. That probably explains the orange light - I assume that indicates the printer has received data, but it will not do anything with it until an end of job PostScript or PCL command is sent, and that command is missing from the jobs being sent to the P1505n, P2055, & P1022n.
    There may be a way to append that command to the job's end using the POS software you are using. For that PAHU is much more likely to suggest something useful than I.

  • About command-line arguments

    it seems a simple problem, but i don't know why i cannot execute that. for example, for (int i=0; i<args.length; i++)
    System.out.println(....)
    using this, i suppose can input something through keyboard. but when i run the program, it doesn't wait for any input and then finish. any one know where is the problem?

    I just skimmed through your posts. Not sure but maybe you are trying to do this. (Forgive me if I'm off track)
    import java.io.*;
    public class saveTxt {
       public static void main( String args[] ) throws IOException {
          FileOutputStream out = new FileOutputStream( "saveTxt.txt" );
          DataOutputStream d = new DataOutputStream( out );
          DataInputStream in = new DataInputStream(System.in);
          String s1;
          try {
                while ((s1 = in.readLine() ) != null) {       
                PrintStream p = new PrintStream( out );
                p.println(s1);
             in.close();
          catch (IOException e) {
          System.out.println ("\n" + '\u0022' +"Test6.txt"+ '\u0022'+ " file created" );     
    }

  • Command line calling

    Hello everyone,
    I am a PhD student in Stockholm, studying VoIP technology. I am in the middle of writing my dissertation, about command line calling.
    As I'm doing my researches, I've already found some very interesting research material, such as this page:
    XxXwww.voip-sip-sdk.com/p_251-how-to-use-the-command-line-caller-example-with-ozeki-voip-sip-sdk-voipXxX (cancel the X-s)
    It would be great to find someone to discuss this program, or maybe a whole group, because it would really help me with moving on.
    Any advice is welcome!
    Thx
    gemma

    >> The problem is the how to call this loader command remotely from our file adapter OS command line.
    The below link might be helpful ...
    http://wiki.sdn.sap.com/wiki/display/XI/SAPXIFileAdapterOSCommandLine+Feature

  • Command Line Parameters Nightmare!

    My issue--and it seems to only be my issue--is with the Command Line Parameters. I have been trying to install iTunes 5.0 for five days now. I have tried everything posted in these forums. Dmitry, thanks for such a great resource; it helped some, but not with this one problem, unfortunately.
    Anyway, everytime I open the iTunes installer I get a message about command line parameters. It gives me a list of a bunch of parameters that I know nothing about. If you would like to see a screen shot of this travesty, you can go to this link: http://staff.fcps.net/nfish/specialdownloadspage.htm.
    Anyone know how to fix this problem or know an alternative solution? Thanks.

    I solved my problem...Everyone who has this problem needs to go see Tim's incredible solution at Nathanael Fish, "new error......" #13, 09:55am Sep 23, 2005 CDT
    It will fix this problem, guaranteed.
    Nate

  • Compile REP file from RDF in the command line

    Is it possible to compile the REP file from an RDF in the command line? If so, do you have a simple example?

    Hi ,
    In 9i, it is rwconverter.exe. Please see Publishing Reports to the Web document available at OTN site.
    &lt;http://otn.oracle.com/docs/products/reports/content.html&gt; and to get more info on how to use rwconverter as command-line refer to "Appendix A" (which would provide information about command-line arguments.
    Hope this helps.
    Thanks,
    Vinod.

  • Latest DNG converter not working in command-line mode

    Today I downloaded Adobe's latest DNG converter. It is failing with both .NEF and .CR2 files when run in command-line mode. It does appear to work in GUI mode. The switches+arguments I've used for my tests are:
    -u -e -p1 filename.CR2
    (or filename.NEF)
    With an older (CS2) version of the converter, the above arguments produce a .DNG output file as expected (with .CR2 files; I didn't try it with D3 .NEF files; surely that older version doesn't support the D3's format).
    With the very latest version, running the program with the above command produces no output. There's no error message.
    The 'readme' file that comes with the converter doesn't include any information about command-line usage, but I did find a PDF file covering this (adobe.com/products/dng/pdfs/dng_commandline.pdf). The switches+arguments shown in the PDF file appear to be exactly the ones I used in the past.
    I'm sure I'll need to use the most recent version to convert D3 RAW files. Is there something wrong with how I'm specifying its command-line switches/arguments?

    It struck me silly that I've been running tests with v.3.3 when 5.2 is the latest, so I downloaded it. The setup "wizard"...hmm, why is it a "wizard"? It provides no choice of installation path. I didn't realize this because immediately after I'd launched it, I knocked something onto the floor, reached down to pick it up ... and looked back up just in time to see the "wizard" complete the installation...but where, I didn't know. It didn't display any information about where it had installed the app. Adventures In Discoverability. :) I hunted around on the hard drive until I found it (C:\Program Files\Adobe -- well, at least you can launch it if you think to look for it in the 'Start' menu). So ... that needs a bit of work. Anyway, I copied the app into a directory of my choice -- one that's in my system's %PATH%, replacing spaces in the name with underscores. It works fine in that directory -- no problem with the name-change as far as I can tell. Now back to the fun stuff...
    This version doesn't seem to require a fully qualified path to the input file or to the output directory when "-d" is used. That's an improvement. IOW, this worked:
    converter -p1 -d DNG filename
    where "converter" is the program's name, "DNG" is the name of a subdirectory of the directory where I'm running the test, and "filename" is the name of a RAW file in that directory.
    The program still doesn't know how to create a directory (or ask about creating one if it doesn't exist). Fails silently if "-d" is used and the specified directory doesn't exist. But at least this version returns an exit code of 1 due to the failure -- better than returning 0.
    Still doesn't understand wildcards. Hope done sprang eternal there for a moment, but oh well. Back to "for" loops...
    Still fails silently, returning exit code 0 (oops), if a nonsensical command-line is used (e.g., using "-c" as the only argument).
    Hey, how about a truly silly command-line error -- a command line including both "-c" and "-u". What happens? It "consumes" the first of the two mutually exclusive switches, ignoring the second -- you get a compressed DNG file. Swap the order of the switches, and you get an uncompressed file. (I'd vote for a syntax-error message in that case, m'self.)
    Interestingly strange little program...If I run it from the command line, it drops back to the command line immediately after I press ENTER. That makes it appear to have failed. But it hasn't -- it's running in the background, and a few seconds later the DNG file is created. But, if I run it from within a batch file, it does NOT return control to me until it has completed writing the output file. Wonder what's up with that.
    Fun stuff. :)

  • Command line archive program to archive the target file

    Hello,
    I need to archive the target file in a ZIP file.
    I heard we need to use a command line archive program to do that.
    Can you guys provide me some info about command line archive program, where to place this program, command line to be executed? etc.
    Thanks in advance,
    Namadev

    below links will help you
    module to zip and unzip
    module to zip and unzip
    Zip or Unzip your Payload with the new PayloadZipBean module of the XI Adapter Framework
    Working with the PayloadZipBean module of the XI Adapter Framework
    SAP XI acting as a (huge) file mover
    The specified item was not found.

  • Develop a command-line application using LabVIEW

    Hi,
             Is it possible to generate a command line(CLI) executable using LabVIEW? This CLI exe will be called with certain command line arguments by another application (written in Visual Basic). The LabVIEW Run time engine can be installed separately on the host PC.
    Thanks for your help
    Siddharth 
    Solved!
    Go to Solution.

    There is an example that ships with LabVIEW that shows how to read the command line arguements from an application. THe name of the VI is CommandLine.vi. It is extremely basic though. The power of command line arguements really comes from how you define and parse them. I recommend allowing your command line arguements to be order independent and that they require a label. For comand lines I prefer to use a single letter for the label. Full words are nice but then your command line gets very long. For the applications that we write we allow both the '/' (DOS/Windows style) and the '-' (Unix/Linux style) to designate a command line label.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Command line for DISCOVERER 3.1.37

    I try to found the instructions about the command line for DISCOVERER 3.1.37 (how to activate with the username/password with the address of a workgroup on a file server)
    Where can i find informations about Command line mode and examples ?

    Hi,
    I think you need to upgrade Disco to 4.1.48, I don't think 4.1.37 works properly with Applcations 11.5.8.
    Rod West

Maybe you are looking for

  • Data recovery from a nonfictional Macbook Pro?

    I have a 2010 Macbook Pro and earlier this evening, I think it might've given up. I closed the lid and opened it up a few minutes later and the screen wouldn't light up. So i restarted it and got this File with a question mark image on my screen. I d

  • How to set the width of DataGridColumn dynamically?

    What I want to do is, load data from a text file and put into a DataGrid component, the fields of ech record in the text have fixed length, and are seperated by a space, like this: personal.txt 50 Uvwxyz  Male    123456789 60 Hijklmn  Male    6789012

  • I cant find the end button when i receive a incomming call please help me. Is there any solution for it or is it a bug in the ios7.0.3 iam updated with ios7.0.3

    I cant find the end button when i receive a incomming call please help me. Is there any solution for it or is it a bug in the ios7.0.3 iam updated with ios7.0.3

  • Use enite page

    I have a BI Publisher report that I want to print right to the bottom of the page. I can't get it to print all the way to the bottom of the page, there is always around a 2 inch white space at the bottom, and then it wraps to the next page. This happ

  • Migo_gr & other is migo

    I i want to investigate one thing for my user exit ,There are two t.codes for MIGO ,one is migo_gr & other is migo, I want to check whether the user has used t.code MIGO OR migo _gr, how it can be checked please let me know Edited by: Sameer.S on Jan