How to run command line argument programe

Hi guys, I am doing pass command line argument programe in java but I don't know how to run this programe. Path for this programe in my my computer is C:\Users\Desktop\Mainjava\mycode\CommandProgjava*
{code/}
public class CommandProg
public static void main(String[] args)
System.out.println("d");
for (int i = 0; i < args.length; i++)
System.out.println(args);
{code/}
Where i need to go and what command i need to give so i can execute this programe(I am using window vista). I only know i have to give
this command some where CommandProg arg1 arg2 arg3 arg4. Output should be
Output:
arg1
arg2
arg3
arg4
Please help me, Thanks in advance.
Edited by: JayVirk on Dec 30, 2007 11:33 AM

Jay,
Your question isn't very clear, hence Joerg's well meaning but irrelevant advise.
Do you mean:
I've written a simple program in java which echos
it's command-line arguments to back to the console.
Here's my code:
package forums;
public class ArgsEchoer
  public static void main(String[] args) {
    for (String arg : args) {
      System.out.println(arg);
But can't figure out how to compile and run the program.
I'm using winblows shista, and it's cr@p.
Please help me, Thanks in advance.So... where are you at? Have you installed the JDK (java development kit)? Which version? Is your path set? Is your classpath set?
Start here: http://java.sun.com/developer/onlineTraining/new2java/

Similar Messages

  • How to give command line arguments

    does anyone help me out in how to give command line arguments after run my program
    m using netbeans6.0.1

    If you want your program to take console input while it's running (as opposed to command line arguments, which are passed once, when you start your program), you can wrap a BufferdInputStream or a Scanner around System.in.
    [http://java.sun.com/docs/books/tutorial/essential/io/index.html]

  • How to add command line arguments to shortcuts in the LV8.5.1 installer

    I want to create multiple shortcuts to my LV program, each with different command line arguments.
    I can do this manually.
    I want the installer to generate these shortcuts.
    I can add different shortcuts in de installer build specification, but I cannot add commandline arguments in the shortcuts.
    Does anyone know how to do this?
    Rindert 

    Hello Forum,
    Does anyone have any better data for this?  I would also like to create an installer using Labview Project Explorer tool (Build Specification->Installer), and I have a need to create some shortcuts to some EXE's (VS.NET built, not LV) which need to have some arguments passed.  I just verified that LV8.6 still does not seem to offer the option of passing arguments when creating shortcuts.  Is this correct?   Creating stub EXE's or batch files isn't a good option for my project, so I'd like to have someone confirm if LV installer tool can't create shortcuts w/ arguments before I fire up InstallShield.
    Regards!

  • How to count Command-Line Arguments ?

    How do you count Command-Line Arguments ?
    For example,
    java program argument1 arguement2
    I would like to be able to count how many arguements the user inputed
    It should result as 2 for the bold line above
    Thank you for your help

    public static void main(String[] args) {
        int numArgs = args.length; // args holds argument1 and argument2
    }

  • How to Pass Command line arguments to an exe created in LV8.0

    Hi Friends,
    I have Created an exe in LV8.0, which accepts the Folder path as input and executes.
    I want to call this exe passing the parameter (i.e folder path in my case)  from the command line argument. How to pass arguments to the exe ?
    Generally we may be having different types of input parameters to a vi like numeric control, string, boolean etc..If we create an exe that needs three input parameters among which one is boolean, other is string and third is a numeric value.
    How to pass these different types of input controls to the exe as parameters in command line at the same time?
    Thanks and Regards,
    SODLB

    I don't have any experience with the 8.x application builder, but the 7.x one has a checkbox for passing the arguments to the executable.
    As for reading them, there should be an example in the example finder (Help>>Find Examples) which shows how to do this. If you want to pass multiple parameters, I suggest you use a structure similar to NAME=VALUE, so that you can parse each element to find the = and then use a case structure to decide what to do with the parameters. This allows your users to enter or not enter any of the switches.
    Try to take over the world!

  • How to pass command line arguments to Web Start appclient?

    Hi,
    I would like to pass arguments to appclient, but "javaws" unable to do that.
    Do I have to overwrite the JNLP? I use Sun Appserver 9.0, it creates JNLP on the fly!!!
    Please help, thanx!
    MB

    Hi, MB.
    If you are talking about the automatic Java Web Start support for launching app clients in GlassFish, you can pass the equivalent of command line arguments using the query string of the URL you use to launch the app client.
    Briefly, use
    http://host:port/client-path?arg=first-arg&arg=second-arg& ...
    specifying the argument values in the order that you want them passed to the client.
    The GlassFish server will do the right thing and generates the correct JNLP so your arguments are passed to the app client.
    The GlassFish developer's guide http://glassfish.dev.java.net/nonav/javaee5/docs/AS91DG.pdf discusses this and all aspects of the Java Web Start support. You can also take a look at this blog entry http://blogs.sun.com/quinn/entry/command_line_arguments_and_properties that focuses on how to pass arguments.
    Since this technique deals with argument passing in the URL, it works no matter how you launch the app client: a URL in a browser, the javaws command, etc.
    - Tim

  • How to pass command line arguments to JWS app

    Hi,
    I want to pass command line arguments to my JWS application. However those arguments are dynamic (eg the username of the user who launched the app) and thus I can not use the argument tag of JNLP file. So what do I need to do in this case?
    Thanks.

    Well, if it's the username on your server systems you should probably include it in the jnlp: can pass it in the url, write once and remove jnlp href attribute, etc.., etc.. (a quick tour of this forum should suffice).
    If it's the OS username you should be able to retrieve it through system properties.
    Whatever it is, passing dynamic arguments means launching javaws through a shell or a shell script (bat if running on windows), so you won't be able to launch through autogenerated desktop and menu shortcuts.
    Anyway, you have two solutions:
    Clean one: associate an extension to your app and write those infos in a file named after that extension.
    Dirty one (always seen it work, but there's no warranty): javaws -open whateverParamYouLike yourAppURL.jnlp, will pass to your main method '-open' as args[0] and '+whateverParamYouLike+' as args[1]. I gotta admin I used it, but I had the most peculiar reason (my app needed another instance on a different JRE aware of being a secondary instance at startup time).
    Bye.
    PS: I'd really love dukes ;-)

  • Ant: how to get command-line argument?

    When using Ant to build Java source files, what is the syntax of obtaining command-line argument in build.xml?

    From the documentation:
    http://ant.apache.org/manual/running.html#libs
    Examples
    ant
    runs Ant using the build.xml file in the current directory, on the default target.
    ant -buildfile test.xml
    runs Ant using the test.xml file in the current directory, on the default target.
    ant -buildfile test.xml dist
    runs Ant using the test.xml file in the current directory, on the target called dist.
    ant -buildfile test.xml -Dbuild=build/classes dist
    runs Ant using the test.xml file in the current directory, on the target called dist, setting the build property to the value build/classes.
    ant -lib /home/ant/extras
    runs Ant picking up additional task and support jars from the /home/ant/extras location
    steps:
    - You define a property (like ${my.prop}) in your build.xml
    - You define it in the command line, like
    ant -Dmy.prop=chosen_value compile
    where "compile" is the target and "-Dmy.prop=chosen_value" defines the value of the property "my.prop" as "chosen_value".

  • How to run command line tool in my program???

    Hi,all,I've got some tools that are usually,or take JDK for example,if we are not using an IDE,we need to open the command prompt,and then use the javac command to compile the source files and the "java "command to run the program,and both of them accept some command line params.The problem is that how could i integrate the tools in my own program,like JBuilder or some other IDE,you configure the params and compile and run in the IDE which don't need to open a command line prompt.Hope i have got my question clear:)
    Best regards..

    jesperdj ,thanks:)
    actually,i am using eclipse to run my ant tasks programmatically,but I got trouble with the AntRunner class.it seems that i should config a proper classloader for it,but i just don't know how.please lend a hand:)thanks
    robin

  • How we run command line commands in oracle

    Hi,
    In sql server i have an option "xp_cmdshell" i can run windows commands e.g "dir " using query analyzer.
    How can i do same thing in oracle
    Thanks in advance.
    Regards
    Faheem

    > MY SELECT:select OSexec('dir') as STDOUT from dual;
    ERROR:-1command[dir] The handle is invalid.
    In the sample code, I've executed a Linux/Unix program called date, physical file /usr/bin/date.
    Is there a DATE.EXE or a DIR.EXE program that you can execute on Windows?
    No. Both DATE and DIR are commands of a program - a 32bit console program called CMD.EXE.
    Your confusion stems from thinking that OSEXEC is calling the Windows shell command line. It is not. It is not calling CMD.EXE and passing Window Shell Commands to CMD.EXE.
    OSEXEC is calling, via Java, the Win32 API call called CreateProcess(). This is a call to the Win32 kernel. It requests the kernel to load an executable program as a process image.
    The kernel expects an EXE (or executable) file to load. You are passing it a command from a program. You just as well can pass it a Java command, a MS Access Basic Command, an Excel Macro, etc... Same thing. The kernel has no idea that this "command" needs another program to be loaded, and that command be "passed" somehow to that program.
    So, you need to call CMD.EXE via OSEXEC. And you can pass parameters to it. Open a Command Console and type cmd /? for help on the command line switches and parameters for CMD.EXE.
    I believe the following should work:
    SQL> select OSEXEC( 'c:\windows\system32\cmd.exe /c date /t') from dual;

  • How to validate command line arguments

    Hi good programmer.Can anyone help me with this problem.I want want to control my program which accept values from command line,in such a way that when I run it without entering arguments in the command line, it must display message that i must pass argument from command line instead of display the runtime error.
    please help...
    victor

    Then you can check that you have the right number of args and print out a message and exit if you don't
    e.g.
    if (args.length != 2)
    System.out.println("This program needs two arguments");
    return;
    Answer provided by Friends of the Water Cooler. Please inform forum admin via the 'Discuss the JDC Web Site'
    forum that off-topic threads should be supported.

  • How do SQR command line arguments work?

    Hello,
    I am using sqrw version 8.52.  I would like to run SQR's for testing purposes from the command line with no user intervention.  I found documentation that says I can do something like this:
    "C:\Program Files (x86)\PT85206\bin\sqr\ora\BINW\sqrw" nint268.sqr USERNAME/PASSWORD@DATABASE PARAM1 PARAM2 PARAM3 "-zifC:\users\kramej3\pssqr.ini" "-iC:\Program Files\PT85206\bin\sqr\;C:\temp\sqr_run\;"
    ...where PARAMx is a parameter that is passed to the INPUT statements in the SQR (first PARAM to first INPUT, second to second, etc.)  Unfortunately, it doesn't seem to want to work this way - the parameters are not passed to the program.  Am I doing this right?
    Alternately: is there a version of sqrw that runs as a console application and does not spawn another window to do so?  If I could have sqrw run as a console application, I could get around the parameter requirement by spawning sqrw.exe via a Python script and then attaching to the stdin and stdout file handles.
    Thanks!
    -JK

    See peoplebooks on this subject.
    I believe it is flags before arguments
    PeopleTools 8.52: SQR for PeopleSoft Developers
    Home > PeopleBooks > PeopleTools 8.52: SQR for PeopleSoft Developers > Using the SQR Command Line

  • How to run command line in LABVIEW 7.1

    Dear Sir/Madam,
    I want to execute such as command like this:
    c:\data\rename aa.txt aa.hex
    In LABVIEW 7.1, how do we implement this command. I really appreciate your help on this matter.
    Regards,
    Xia

    Use the sys exec function.  In LV 7.1 it is in the Communications palette.
    paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • SSIS - How to run command line to copy files with User Variables within a Execute Process Task

    Hello,
    I'm am having syntax issues within the Arguments when trying to copy a file with cmd.exe using User Variables.
    It works when I hard code the arguments : /c copy /b  "\\folder1\file.txt" "\\folder2\file.txt"
    However, it's failing when I try using User Variables to replace the directory and file.
    User::FILES = \\folder1\file.txt
    User::FILE_NAME = file.txt
    "/c copy /b + @[User::FILES] + \" \\\\folder2\\" + @[User::FILE_NAME]"
    Does anybody know what's wrong with my syntax?
    Thanks!

    Hi SSISBeginner,
    Assuming the source file is "C:\Temp\Source\file.txt", the destination folder is "C:\Temp\Destination", the expression of FILES variable is "C:\Temp\Source\file.txt", and the expression of FILE_NAME variable is file.txt. Then, we can use the following
    expression for the Argument property of the Execute Process Task:
    "/C COPY /B "  +  @[User::FILES] + " C:\\Temp\\Destination\\" +   @[User::FILE_NAME]
    Note: Pay attention to the spaces in the double quotes in the expression.
    Regards,
    Mike Yin
    TechNet Community Support

  • Obtaining command line arguments

    Can someone point me at an example of how to obtain command
    line arguments from inside my Flex application? I want to have my
    Flex application perform different tasks when it is launched with
    different command line arguments, for example:
    myApp.exe 1
    myApp.exe 2
    myApp.exe 3
    How is that done in a Flex app?
    TIA,
    Steve

    "plug_in_guy" <[email protected]> wrote in
    message
    news:gnfgf2$ir1$[email protected]..
    > Can someone point me at an example of how to obtain
    command line arguments
    > from
    > inside my Flex application? I want to have my Flex
    application perform
    > different tasks when it is launched with different
    command line arguments,
    > for
    > example:
    >
    > myApp.exe 1
    > myApp.exe 2
    > myApp.exe 3
    >
    > How is that done in a Flex app?
    This may help:
    http://www.davidtucker.net/2008/01/23/air-tip-7-using-command-line-arguments/

Maybe you are looking for