Coomand line args in Eclipse

Hi,
I have a main class in my eclipse project and have to exceute :
java -jar sims.jar -cfg sims.cfg -conn test.sim -data data.txt -send 1 1 1
how do I do this in Eclipse? I gone Run->run and put that line in VM arguments but it won't work - please help!!
Tri

You entered the whole command line in the arguments field:
java -jar sims.jar -cfg sims.cfg -conn test.sim -data data.txt -send 1 1 1
and you got a java.lang.NoClassDefFoundError: java .
This is normal because Eclipse tries to take the first java as argument. But it isn't; it's the name of the Java interpreter!
You have to enter just
-jar sims.jar -cfg sims.cfg -conn test.sim -data data.txt -send 1 1 1
as command line (not VM!) arguments, and Eclipse should execute the main class specified in the manifest of the jarfile.
Otherwise, run
java -jar sims.jar -cfg sims.cfg -conn test.sim -data data.txt -send 1 1 1
directly as command line (shell or the Windows command prompt). Is there a reason why you wanted to use Eclipse instead?
Message was edited by: java_knight

Similar Messages

  • Include command line args in executable jar?

    Hello all,
    I'm trying to package up some software which takes 2 command line args to run (for example, java -jar prog.jar FooBar 3.14159). I'm using a utility called Jar2Exe to wrap it up into an exe (still needs JRE to run, but it's nicer packaging for distribution).
    My question is, how can I included command line arguments in the jar? Or can I? Or, are there any exe-wrapping utilities out there that will allow me to accomplish this?
    Thanks,
    -Thok

    Thok wrote:
    Hello all,
    I'm trying to package up some software which takes 2 command line args to run (for example, java -jar prog.jar FooBar 3.14159). I'm using a utility called Jar2Exe to wrap it up into an exe (still needs JRE to run, but it's nicer packaging for distribution).
    My question is, how can I included command line arguments in the jar? Or can I? Or, are there any exe-wrapping utilities out there that will allow me to accomplish this?
    Thanks,
    -ThokOkay, did some more research... It appears you can't specify command line options in a jar, but if you package it into an exe, you can--depending on what utility you use to wrap it, that is. I downloaded a free one (Launch4j) and it does the trick.
    -Thok

  • Wrong to process command line args in a loop?

    I tried to process my command line args like this:
    int[] rgb = {0,0,0};
              for(int i=1;i<3;i++)
                   rgb[i-1] = Integer.parseInt(args);
    I enter six args where args 1 to 3 are ints and not zero, but rgb[2] always ends up being zero. I had to do away with the loop and write out three assignment statements, but if I had ten or more args that would be a headache! Does anyone know why this is happening? I'm using JDK 1.3.1_15.

    for(int i=0;i<3;i++)
       rgb[i] = Integer.parseInt(args);
    Look closely and make sure you understand the differences between my code and yours:
    * i starts at 0, not 1
    * rgb uses i for index, not i - 1.
    Why would you have rgb using i -1 and args using i?
    Now, if you have an arg [i]before the RGB args, then it would make sense for args' index to be different than rgb's. In that case, you might have i-1 and i, or i and i+1, etc. depending on how you structure your loop.
    The main problem is that you had i=1; i<3, which will go through the loop body for i=1 and i=2 only. Make sure you understand why.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Command line args

    I have this program and I need to use command line args which
    will print ell . this program does this but I am using
    substring instead of command line args.
    public class h11 {
    public static void main (String [] args ) {
    String greeting = "Hello";
    String h11 = greeting . substring (1, 4);
    System.out.println( h11);
    output: ell
    Anyone..

    First off, the index of characters in a String is 0 based so in the string "Hello" you have the following;
    char 0 = "H"
    char 1 = "e"
    char 2 = "l"
    char 3 = "l"
    char 4 = "o"
    String.substring(start, end) is first inclusive and last exclusive so the parameters (1, 4) would return characters 1, 2 & 3 but not 0 or 4.
    To get the whole word Hello (not withstanding that that's the entire string) you would want greeting.substring(0,5) however that would generate an index out of bounds error because 5 isn't a valid index for that string. So, here's a small sample program to show how to do what I think you're after.
    public class ParmsTest{
         public static void main(String[] args){
              if( args.length > 0 ){
                   String parm = null ;
                   int end = 0 ;
                   int start = 0 ;
                   for( int i=0; i< args.length; i++ ){
                        parm = args[i] ;
                        if( parm.length() > 4 ){
                             end = 4;
                        else{
                             end = parm.length() - 1 ;
                        if( end > start ){
                             System.out.println( parm.substring(start, end) ) ;
                        else{
                             System.out.println( "Nothing to get" ) ;
              System.out.println( "Finished processing parameters" ) ;
    }It's a bit more complicated than your sample, but it also checks to see if there were any parameters, and it checks to see if the length we're trying to get is valid. Lastly it checks to see if there was anything to get before trying to print it. If it doesn't find anything to print it prints a message saying so.
    Here's the question I have for you. Why? Why did I go to this trouble?

  • Line args

    I'm trying to pass command line args to my application but i'm not sure how to add in support for dynamic arguments. In my assignment, I have to output the names of 5 family members, and also add support for extra arguments --so if someone adds a "name" of a family member as an argument, my program should output the name, and all it's related information, such as surname, age etc., and also be able to support multiple names for arguments.  Is there a way to do this?
    So far, I've been able to output all the information at request, but it's the multiple arguments (which might be in any order) combined with their respective element values that stumps me.
    If I have:
    else if(args[0].equalsIgnoreCase("Michael"))
    output += "\n" + (firstName[counter] + " " + lastName[counter] + " "+ memberAge[counter]).toString();
    would I have to write a switch, or if/else statements for each and every name in the family, and each and every combination of arguments? For instance, if they used "dad, mom, sister, brother" as arguments (which could be in any order), how would I write that into a statement?

    I think what you want is for people to enter "dad mom sister" as command line args and then your code will know what dad's info is, etc? If that's the case, then you can do this:
    Map family = new HashMap();
    family.put("dad", dadsPersonObject);  // store a person object in the hash associated with the word dad
    for(int i=0; i<args.length; i++){
       Person p = (Person)family.get(args); // use command line string to lookup their person object from hash
    // print out person info here
    So, for this to work you'll need to have some object that stores person info, fill some person objects with the family members info, put them all in a hash with their command line strings as the keys, then for each command line arg. get the associated person object from the hash and print their info.
    Is this what you're looking for?

  • Bash number of command line args....

    Hi,
    Is there a way in bash to get number of command line args ...
    atm I am using $1 but of course if you pass a command like uname -a you need two?
    wondered if there is a $<foo> that ill give number of args passed?
    EDIT looks like '$#' emmmm lets see....

    woah!!! ok thanks ..... $# gives me number of args ... will check it out
    $1 $2 > /tmp/cmd
    messy way.....

  • Line Numbers In Eclipse

    Hey is there any way you can configure eclipse so it will show line numbers in the editor...
    thankx.... matt

    never mind... I found it

  • 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/

  • JAXRPC--adding cmd line args to client

    Hi,
    I followed all of the steps in the Java Web Services Tutorial for JAX-RPC to run the HelloWorld example and everything worked as outline on pages 335-341 of the tutorial. ONE BIG QUESTION: How can I add my own argument to the client so that, instead of displaying "Hello Duke!" (i.e., "Hello <whatever is hardcoded in HelloClient.java>!"), I can display "Hello <cmd line argument>"
    Thanks,
    marcia

    In HelloClient.java, change the sayHello call to:
    System.out.println(stub.sayHello(args[1]));
    In the build.xml, add this line to the run target
    below the arg line for the endpoint:
    <arg value="${msg}" />
    To run the program and specify "Bob" as the argument:
    ant -Dmsg=Bob run
    For more info about passing arguments to ant, please
    refer to the Ant User Manual (see the core task named
    "java"). The manual starts at the
    docs/ant/manual/index.html file.
    Hope that helps. -- Dale

  • Sun Studio 12 - Can't specify command line args while profiling

    New to Sun Studio development environment, and having trouble profiling my application. I have specified command-line arguments for both Debug and Release builds in Project/Configuration Properties/Runninjg/Arguments and this works fine when running the project from within the IDE. However when I attempt to profile the application through IDE Advanced/Advanced Profiling/Start, my application is launched with no command line arguments. So far I have been unable to find any place to define command line arguments for the program when run using the profiler. Any insights would be greatly appreciated.
    Regards,
    Chad.

    Yes, there is a bug. I reproduced the problem using a sample project Welcome. If I run it without profiling, the program prints correct arguments:
    Welcome ...
    Arguments:
    1: arg 1
    2: arg 2
    [Press Enter to close window] If I run it with profiling "Advanced->Advanced Profiling->Start", the program prints wrong arguments:
    Running "/export/home/SunStudio/SUNWspro/prod/bin/collect  -d /export/home/nikm/SunStudioProjects/Welcome/nbproject/private/experiments -o test.1.er -A on   -p on  -S on  /export/home/nikm/SunStudioProjects/Welcome/dist/Debug/welcome arg 1 arg 2" in /export/home/nikm/SunStudioProjects/Welcome
    Creating experiment database /export/home/nikm/SunStudioProjects/Welcome/nbproject/private/experiments/test.1.er ...
    Welcome ...
    Arguments:
    1: arg
    2: 1
    3: arg
    4: 2
    5: null
    Run successful. Exit value 0.Note, it got 5 arguments instead of 2.
    So, there are two bugs:
    1. argument with spaces is transformed to several arguments.
    2. a "null" argument is added to the list.
    I'll file this bug and let you know the number.
    A workaround is to ignore the last argument in your
    program if it is "null", but this is a very ugly workaround :-)
    Thanks,
    Nik

  • Passing command line args

    I'm a beginner in java and I need to know now to write the code that takes in a randon number of numbers at the command line and stores them in an array
    ie. the program is called number and when I run it, it has to take in the numbers at the command line
    ie. java numbers 12 13 14 15 19 1
    then these numbers are to be stored in an array
    How can I do this??
    Thanking you
    Tom

    public class Numbers {
        public static void main(String[] args) {
            // Convert to integers
            int[] param = new int[args.length];
            for ( int cnt = 0; cnt < args.length; cnt++ ) {
                try {
                    param[cnt] = Integer.parseInt(args[cnt]);
                } catch (NumberFormatException nfe) {
                    System.err.println("Argument " + cnt + " is not integer, using '-1'");
                    param[cnt] = -1;
            // use integers ...
    }

  • Printing line numbers in eclipse

    I'm on Windows XP and I must print out the line numbers when I print out source code. However, I can't find how to do this in eclipse. Does anyone know?? I've tried everything.

    never mind... I found it

  • Reading directory path as command line args

    Hello,
    I'm trying to write a simple java web server that serves files from a specified directory over a specified port no. (both specified at the command line).
    I am just wondering if any one has any advice on how to handle the directory argument and how check that it is valid etc.
    Thanks
    Gary

    Take a look at the File class, and the method isDirectory, and exists.
    Kaj

  • Environmental variables as command line args

    Hello, all,
    I would like to pass an environmental variable as a command line argument for a java program.
    Example:
    java MyClass $MY_VARIABLE
    However, it actually passes "$MY_VARIABLE", and not the value of MY_VARIABLE. I know that I can use java -D(MY_VARIABLE=SOMETHING) and get it using System.getProperty ("MY_VARIABLE");
    However, I would prefer it the first way, actually passing the variable inside command line. Is there a way to do this?
    Thank you,
    Elana

    Nevermind... Error in my code... It works
    Thank you

  • Include command line args in jar file

    If I make and executable jar file, how can I make it so that when it runs certain comman line arguments are included

    If by "executable jar" you mean that you want to click the jar and run the program (and are using Windows), then you would have to alter the Windows file association for jar files that Java created, adding those options to the javaw command. Note that that would affect all jars that are run this was.
    If you're willing to use the "javaw -jar" command, then just add the options to the javaw command.

Maybe you are looking for

  • Problem invoking a web service from soa11g BPEL.

    Hi , I am trying to invoke a web service from soa bpel 11g composite. We have the wsdl, wsdl URL of the web service along with the user name , password credentials. Initially w/o any WS policy attached and testing the composite, it fails with the bel

  • NUMERIC TextField with max length

    Hi there guys, could someone tell me why TextField's get a 10 number max length automatically when it's assigned a NUMERIC type to it? Even if I set it's max length to more then 10. I know it doesn't happen in most of cellphone's models but I've alre

  • Not able to log on EAS console

    Hi everyone i have a problem with my EAS services, weekly once my windows server will be restrat, on the first day of my week, i have to restart manually my EAS services thogh it was started, then only i can log on to my EAS console it will happen wh

  • Reinstall downloaded game on N80

    Hi, I have an Orange Nokia N80 and recently downloaded the new Tomb Raider Legend game. I installed the game to my memory card and the shortcut showed up in the menus but when I went to start the game it said 'No more memory'. I have been having prob

  • Document created on mac with Yosemite not appearing on iOS devices

    i prepared a document on my Mac using Pages and expected to find it on my iOS devices. That  has not happened and I cannot find out why.  All software on all devices is up-to-date.