Use as objects arguments in the command line

Hello :)
how can i use the arguments in the command line as objects
java xxx file.txt file2.txt
the program get as args[] those arguments
args[0] .... file.txt
args[1.... file2.txt ..... n
i don t want to write the arguemnts in the command line i want to use it as an object for example :
File file = new File ("c:/somedirectory/file.txt") ...
plese help me
thanx

I did it
easy cake
String s = "a.txt";
String args1[] = {
"-o", s };
c u

Similar Messages

  • Counting arguments in the command line

    I need to write a snip of code that will check the command line to make sure there are 5, no more or less, arguments. If not I have to return an error message. Anyone have any ideas?
    Stephen

    The command line args will be in a String[] passed to main(). Arrays have a length field that tells you how many elements they have.
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html

  • [svn] 2716: SDK-15848 - Conditional compilation constants defined in flex-config. xml are never used if a single constant is specified on the command line

    Revision: 2716
    Author: [email protected]
    Date: 2008-08-04 01:18:12 -0700 (Mon, 04 Aug 2008)
    Log Message:
    SDK-15848 - Conditional compilation constants defined in flex-config.xml are never used if a single constant is specified on the command line
    * There's a possibility this will break a conditional complication test which disallows overwriting an existing definition -- I don't know if that will break the build, but the test should be removed either way.
    * Using append syntax ("-define+=" on the command line or ant tasks, or append="true" in flex-config) and redefining a value works now if you use an already-defined namespace and name.
    * So your flex-config may have -define=CONFIG::debug,false, and you may want -define+=CONFIG::debug,true from the commandline build, or FB build.
    * Made the ASC ConfigVar fields final as a sanity check since overwriting is now allowed. It would be harder to track changes and subtle bugs if they were mutable. This means that you must build a new ConfigVar object if you need to make changes.
    Bugs: SDK-15848
    QA: Yes. Please read the updated javadocs in CompilerConfiguration. Tests need to be added to validate that overwriting is allowed, and happens correctly in different situations: I believe the order should be that flex-config is overwritten by a custom config (can we have more than one user config? is the order deterministic? I forget...), is overwritten by commandline or OEM. Did I miss any? (I didn't write code which changes this, it works however the existing configuration system allows overwriting and appending; if we have tests for that, maybe we don't need them duplicated for this feature.)
    Doc: Yes. Please read the updated javadocs in CompilerConfiguration.
    Reviewer: Pete
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-15848
    http://bugs.adobe.com/jira/browse/SDK-15848
    Modified Paths:
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/ConfigVar.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/common/CompilerConfiguration.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/internal/OEMConfiguration.java

    Please note: I AM USING:
    JkOptions ForwardKeySize ForwardURICompat -ForwardDirectories
    And that's what's supposed to fix this problem in the first place, right??

  • How to pass in variables using the command line when starting ActionScript native app

    How do I pass in variables or startup arguments using the command line when starting an ActionScript native app? For example, I have my app call MySweetWidget and it has been compiled with Adobe AIR captive runtime so now I have MySweetWidget.exe.
    In the command line, I am calling MySweetWidget.exe and would like to pass in variables or properties to the application. I would assume that those variables are then read from the loaderInfo.parameters object.
    Please let me know if the Adobe AIR runtime supports passing in parameters to the native runtime. If so, I would like help determining the correct format of how to pass in the variables. Then would you read those from the loaderinfo.parameters object?
    Thanks,
    Jeff

    I found the answer to my own question:
    Yes it is a supported feature. It is documented on the following page:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/NativeApp lication.html#event:invoke
    When you subscribe to the invoke event of the NativeApplication it will subsequently dispatch the event and you read the e.arguments Array object to get the startup arguments passed into the native application.

  • How to hide the command line arguments from solaris process

    Hi All,
    When I execute a JAR application from a java file using the Runtime.getRuntime, the command line arguments (user ID and Password details) which I passed for executing the application displayed on Solaris process (ps -ef).
    Could anybody please help me, how can I hide either the process or the command line arguments from the Solaris process?
    I cannot pass any asterix or any special character in place of password, because the executing application doesn't have any functionality to retreive the password which send as asterix characters.
    Please help me
    SumodeV

    Thanks for all the response.
    I have created a design and implement the functionality which executes the JAR application in Solaris environment without showing any details in the process details.
    I have used the Java Reflection method, which invokes the JAR application. I am sharing the details here for all those who looking for it.
    1, Inside the Customer application [Jar File is running for it], collect the necessary session details [Using System.get property method]
    2, Create an independent Java file, which should be used to invoke the JAR application
    3, Create the ProcessBuilder object and use a command - execute the Java file [a wrapper code] using normal Java command
    4, Pass the necessary session details to the ProcessBuilder using the environment() function.
    5. Collect the environment values in the independent Java file (Which was invoked by ProcessBuilder) and set details for its environment using System.setProperty.
    6, Use reflection technique to invoke the JAR plugin [which you want to run]. You can use the standard Java functionality to read the MANIFEST file of JAR and load the main class using URLClassLoader.
    7, Invoke the main method of the JAR file, which run the JAR application in Solaris window
    This solution will make sure that the process cannot display any session details in the Solaris Environment.
    Note: Use String[] array while create the command. Otherwise the JAR application cannot pop-up.
    Regards
    Sumode

  • Error while running aiaconfig.sh - The command line argument(s) "weblogicConfig"

    Hi.
    We are Configuring PIP on AIA 11.1.1.7 after installing AIA PIP release. we we run ./aiaconfig.sh we are getting below error message,
    $./aiaconfig.sh
    Starting Oracle Universal Installer...
    Checking swap space: must be greater than 500 MB.   Actual 169130 MB    Passed
    Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
    Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-11-20_04-11-10AM. Please wait ...adevaia                                                        @soa-odi-dev1:/u02/app/Oracle/Middleware/AIAHOME/bin$ [WARN ][jrockit] MaxPermSize=256m ignored: Not a valid opt                                                        ion for JRockit
    Log: /u01/app/oraInventory/logs/install2013-11-20_04-11-10AM.log
    The command line argument(s) "weblogicConfig" or the install mode specified is not valid.
    Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    Usage:
    config.sh [-mode] [-options] [(<CommandLineVariable=Value>)*]
    Where mode include:
    [Mode is a mandatory parameter. Only one mode can be specified.]
         -silent For silent mode operations, the inputs can be a response file or a list of
                  command line variable value pairs.
    Where options include:
         -help, --help, --usage
                  Displays above usage.
         -invPtrLoc <inventory pointer file>
                  Launches the installer with a custom inventory location. The invPtrLoc
                  should point to a file which contains the following information.
                  inventory_loc=<inventory_location>
                  inst_group=<group_name>
         -response, -responseFile <response file>
                  Specifies the response file and path to use.
         -jreLoc <location>
                  Path where Java Runtime Environment is installed. OUI cannot be run without
                  it.
         -logLevel <level>
                  To filter log messages that have a lesser priority level than <level>.
                  Valid options are: severe, warning, info, config, fine, finer, finest,
                  basic, general, detailed, trace. The use of basic, general, detailed, trace
                  is deprecated.
         -debug  For getting the debug information from OUI.
         -force  Allowing silent mode installation into a non-empty directory.
         -printdiskusage
                  Log debug information for disk usage.
         -printmemory
                  Path where Java Runtime Environment is installed. OUI cannot be run without
                  it.
         -printtime
                  Log debug information for time usage.
         -waitforcompletion
                  For windows. setup.exe will wait for completion instead of spawning the
                  java engine and exiting.
         -noconsole
                  For suppressing display of messages to console. Console is not allocated.
         -ignoreSysPrereqs
                  For ignoring the results of the system pre-requisite checks.
         -executeSysPrereqs
                  Execute system pre-requisite checks and exit.
         -paramFile <location of file>
                  Specify location of oraparam.ini file to be used by OUI.
         -novalidation
                  Disables the validations, can be invoked along with GUI or silent mode.
         -nodefaultinput
                  Disables the default computation of values (pre-populating of values when
                  screen is loaded) in GUI install.
         -nocheckForUpdates
                  To disable all updates checking
         -updatesDir
                  To specify the directory where latest updates are downloaded. This could be
                  used in disconnected mode.
    Command Line Variables Usage:
              Command line variables are specified using <name=value>; for example:
                  [ session: | session:compName: | session:compName:version: ]variableName=" valueOfVariable"]
              Installer variables are specified using:
                  varName=value
                  Ex: ORACLE_HOME=<value>
              OUI Session variables are specified using:
                  session:varName=value
                  Ex: session:VARIABLE_NAME=<value>
              OUI Component variables are specified using:
                  session:compInternalName:[Version:]varName
                  Ex 1: session:oracle.comp1:1.0.1:varName=<value>
                  Ex 2: session:oracle.comp1:varName=<value>
                  The lookup order is compInternalName:Version:varName, then compInternalName:varName
    do anyone had any idea on this.
    Thanks a lot,
    RR.

    try checking relevant environment variables like the CLASSPATH.... a major source of failures in Windows is when in the classpath there is a path containing SPACES.... also enabling some "debug" or "verbose" flag (not sure how to do it) would provide more insight...

  • Using the command line with DESKI to run a specific module in a report

    I'm using BOXI R2 Desktop edition in a Windows Environment.
    I have a report with a macro inserted in it which is composed of several sub-modules. 
    I know I can launch the report from the command line as follows: "C:\PROGRAM FILES\BUSINESS OBJECTS\BUSINESSOBJECTS\BUSOBJ.EXE" -user "USERID" -pass "PSWD" "Directory and Filename" -keyfile "Keyfilename" -nologo
    What I want to know is can I launch the report from the command line and call a specific module.  So if I have 5 modules in a single report, can I just call 1 from the command line?
    How would that be formatted?
    Thanks in advance.

    There's some more stuff to be done to correctly call external executables.
    Read [When Runtime.exec() wont|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html], it shows some of the pitfalls of Runtime.exec().
    Edit: there's also JRuby, which might be worth a try.

  • Pass the command line argument (argc and argv) to a LabVIEW built shared library.

    Hello,
    I have successully use this trick to build a LabVIEW application that runs on Linux without X Display.
    http://digital.ni.com/public.nsf/allkb/5D6EC36DCF43343786257449006919E6
    I'd like to know if it's possible to pass the command line arguments ( ./TEST A B C D) directly into the shared library without having to pass the arguments using a array of strings which would require to write code using DSNewHandle, DSSetHandleSize, extract the arguments and ..... (I'm not proficient in C, but if I don't have a choice I will do it and improve my C skills).
    int main(int argc, char *argv[])
            Test(argc, argv);
            return 0;
    Thanks,
    Michel
    Solved!
    Go to Solution.

    Well, you can always flatten it back into a space separated single string and pass it like that. Basically reverse what the OS does when it calls your main function with the command line parameters. And while the first element in the array is always the program name itself you can just skip that here, but then format all the rest into a single string.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Installing a New Windows Server 2008 R2 Child Domain by Using the Command Line

    Installing a New Windows Server 2008 R2 Child Domain by Using the Command Line:
    http://technet.microsoft.com/en-us/library/cc731873%28v=ws.10%29.aspx
    dcpromo /unattend /InstallDns:yes /ParentDomainDNSName:mysite.com /replicaOrNewDomain:domain /newDomain:child /newDomainDnsName:gridview.mysite.com /childName:gridview /DomainNetbiosName:gridview
    /databasePath:"c:\Windows\ntds" /logPath:"c:\Windows\ntds" /sysvolpath:"c:\Windows\SYSVOL" /safeModeAdminPassword:pass1 /forestLevel:4 /domainLevel:4 /rebootOnCompletion:yes
    Error Code:
    The specific argument 'childName' is not recognized.
    I am trying to insert gridview as a childname.

    Hi,
    Before going further, can we try another domain name to see what will happen?
    Besides, if the issue persists, we can try installing a new child domain by using the GUI.
    Installing a New Child Domain by Using the Graphical User Interface (GUI)
    http://technet.microsoft.com/en-us/library/cc771856(v=ws.10).aspx
    Best regards,
    Frank Shen

  • I am trying to set an open DNS using the MacAir. But when I tried to flush the existing one at utilities/terminal, it will not work.  I am using Yosemite.  May I know what should be the command line so that I can shift to an open DNS?  Thanks

    I am trying to set an open DNS using the MacAir. But when I tried to flush the existing one at utilities/terminal, it will not work.  I am using Yosemite.  May I know what should be the command line so that I can shift to an open DNS?  Thanks

    >SystemPreferences>Network>DNS

  • Can't change activation only mode to off using the command line in Windows 7 64 bit

    I used the command line to turn activation only mode on and now when I use teh command to turn it off it will not change the iTunes setup. I am on Windows 7 64 bit. I tried uninstalling itunes and reinstalling and it is stillin activation only mode.

    Hi! Thx for your quick reply! I am still unsure what to do tho---see my questions below in bold:
    Windows 7 comes with its own version of the standard PostScript driver. = Where is this driver? I have no idea how to find it, it doesn't show up in my Printer menu in FM?
    Given that PostScript generated by a driver can be highly device-specific, you need to install the driver as modified by the PPD file for the device in question. Most printer manufacturers in fact provide a PostScript driver installer that associates their printer's PPD file with the standard Windows Printer driver and subsequently creates what is called a PostScript printer driver instance for the particular device on the I/O port you designate. = ??? I've only updated a PPD file for watermarks and have no idea what this means...is there a step-by-step instruction for this? I just need to download a PS driver to select that works & doesn't freeze up my FM when creating a .ps file.
    The real question thus is exactly what are you trying to generate PostScript for? = I create a PS, & then use Distiller to create a PDF. This enables me to have a PDF that automatically has Bookmarks, the TOC/LOF/LOT & all corss-refs are hyperlinked, etc.
    If you are trying to create PostScript for distillation into PDF, Acrobat installs a PostScript driver instance of its own, labelled Adobe PDF, that is associated with the Acrobat Distiller PPD. = I have tried the Adobe PDF selection from my Printer menu in FM, but it freezes up FM and I have to close the whole program & no PDF generates.
    BTW, although you may be successful in installing and running FrameMaker 8 on Windows 7, in fact Adobe officially does not support FrameMaker 8 on Windows 7. = I don't know what to say---the upgrade is too expensive for some of us folks out here right now, so we all need to work with what we have for now!
    I appreciate your help, thank you.

  • [svn:bz-trunk] 17010: Bug: Watson #2652870 - use a property file to drive the custom configuration tokens as opposed to setting it in the command line

    Revision: 17010
    Revision: 17010
    Author:   [email protected]
    Date:     2010-07-22 02:52:41 -0700 (Thu, 22 Jul 2010)
    Log Message:
    Bug: Watson #2652870 - use a property file to drive the custom configuration tokens as opposed to setting it in the command line
    QA: Yes
    Doc: Yes - in custom tokens section, talk about the new token.file option
    Checkintests: Pass
    Details: Changed TokenReplacer to look for a token.file JVM option. If it's specified (eg. -Dtoken.file=/User/matamel/Desktop/token.properties), then TokenReplacer looks for a properties file where token name and values are specified. This allows someone to specify a file for custom tokens. Custom tokens can still be specified as straight JVM option and in case where a token is defined both as a JVM option and in a token properties file, JVM option takes precedence.
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/config/TokenReplacer.java

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • Connection string not in the command line argument.

    Hi,
    I found myself constantly looking for the debug connection string and to enter it in the "Command line arguments".  I decided to create my Add-On base class from which all my add-ons inherit from.
    In the constructor of the base Add-On class I determine the connection string based on whether the code is in debug more or not.
    Example:
    string connectionString  = string.Empty;
    #if DEBUG
        _connectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
    #else
        // Get the log info
        if (Environment.GetCommandLineArgs().Length > 1 )
            _connectionString = Environment.GetCommandLineArgs().GetValue(1).ToString();
    #endif
    I hope this help.
    Edited by: B1Computing on Apr 5, 2011 8:20 PM

    Hi,
    I found myself constantly looking for the debug connection string and to enter it in the "Command line arguments".  I decided to create my Add-On base class from which all my add-ons inherit from.
    In the constructor of the base Add-On class I determine the connection string based on whether the code is in debug more or not.
    Example:
    string connectionString  = string.Empty;
    #if DEBUG
        _connectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
    #else
        // Get the log info
        if (Environment.GetCommandLineArgs().Length > 1 )
            _connectionString = Environment.GetCommandLineArgs().GetValue(1).ToString();
    #endif
    I hope this help.
    Edited by: B1Computing on Apr 5, 2011 8:20 PM

  • Enterting File to be used at the command line (help!)

    I have this code which works on by loading a .txt which hold a matrix of numbers and doing some maths and the like on it. the problem with this is that it is limited to only being able to read from that one file. i would like to make it possible to enter the name of the .txt file at the command line when running the program
    e.g java FlatCost costs.txt
    heres the code so far (it works).
    import java.io.*;
    import java.util.Vector;
    public class FlatCost
        public static void main(String[] args) throws IOException    {       
            FileInputStream stream = new FileInputStream("costs.txt");
            InputStreamReader reader = new InputStreamReader(stream);       
            StreamTokenizer tokens = new StreamTokenizer(reader);       
            Vector v = new Vector();
            while(tokens.nextToken() != tokens.TT_EOF)        {           
                v.add(new Integer((int) tokens.nval));
                System.out.println(new Integer((int) tokens.nval));        }       
            System.out.println("Enter floor number: ");       
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            String line1 = in.readLine();
            int x = Integer.parseInt(line1);
            if(x > 3) System.out.println("Sorry, out of range");
            System.out.println("Enter no. rooms: ");       
            String line2 = in.readLine();          
            int y = Integer.parseInt(line2);
            if(y > 2) System.out.println("Sorry, out of range");
            int numFloors = v.size()/4;               
            int dest = ((x*4) + y + 1);
            System.out.println("PRICE: " + v.get(dest));   
    }Please help because i dont know how to do it
    Carl

    That's right... specificallyFileInputStream
    stream = new FileInputStream(args[0]);
    Also don't forget make sure the argument was supplied. Otherwise you'll get a runtime array out of bounds.
       if (args.length < 1) {
          System.out.println("Usage: java FlatCost filename");
          System.out.println("   eg: java FlatCost costs.txt");
          // exit or supply default file
       }

  • How do I edit the file where sites which I have typed in on the command line are stored? These are sites which I no onger use.

    At times I type in a site name on the command line which I want to visit. This goes into a file which is accessed by highlighting the triangle on the right side of command line. This file contains previous sites which were accessed in the past. How do I edit this file and and remove previous site URLs?

    Use these steps to remove saved (form) data from a drop down list:
    #Click the (empty) input field on the web page to open the drop down list
    #Highlight an entry in the drop down list
    #Press the Delete key (on Mac: Shift+Delete) to remove it.
    *http://kb.mozillazine.org/Deleting_autocomplete_entries
    *https://support.mozilla.com/kb/Clearing+Location+bar+history
    *https://support.mozilla.com/kb/Cannot+clear+Location+bar+history

Maybe you are looking for