Is it possible to assign a value to args in main method?

I am trying to understand a class and it has a try { } after the main method and it seems to be checking the length of agrs. I keep getting the exception it throws.
I don't understand how you can put something into args or when there would ever be a length to it? It's right at the start of the class! Can anyone explain this to me?
public static void main(String[] args) {
try {
// Check the arguments
if ((args.length != 1) && (args.length != 2))
throw new IllegalArgumentException("Wrong number of arguments");

I keep getting the exception it throws.Yes, you will.
I don't understand how you can put something into args.RTFM... seriously http://java.sun.com/docs/books/tutorial/essential/environment/cmdLineArgs.html
or when there would ever be a length to it?Allways.
It's right at the start of the class!It's not is it. Oh golly gosh. Run for the hills everyone... they've put argument processing at the start of the program again. ;-)
Can anyone explain this to me?Yes millions of people can. But you forgot the magic word.
  public static void main(String[] args) {
    try {
      // Check the arguments
      if ((args.length != 1) && (args.length != 2)) {
        throw new IllegalArgumentException("Wrong number of arguments");
     ....Edited by: corlettk on Oct 1, 2007 11:57 AM

Similar Messages

  • Is it possible to assign a value to a radio button or checkbox?

    I would like to assign radio buttons or checkboxes a value and then have the results of the buttons selected tabulated at the end of a form, if desired. Is that possible? Thanks

    Thanks for your reply and help. I appreciate it. I was able to get an export value added to the check box, but did not see and option for a radio button. But the check box works fine for now. Thanks again.

  • Assigning a value to a substitute variable

    Hi, I would like to know if it is possible to assign a value to a substitute variable.
    This is what I'm doing:
    - Prompting user for input
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    (displayed list of options are numbers 0-5)
    - Based on input, open corresponding file
    (start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql)
    Problem:
    - Default selection is 0, meaning use the CURRENT UOM system (a number, 1-5)
    - That being said, &&uom must be assigned a 1-5 value in order to open the file that corresponds to the CURRENT UOM system
    Let me know if any additional information is needed.
    Thanks!

    I apologize for the format. I tried to make it more legible, but was not able to. FYI: It appears to be easier to read in "Edit" view.
    Thanks, I tried the &&uom := your_function(); suggestion, but I am getting an error. It looks like the "value" of &&uom is being read in the assignment statement, not the variable name.
    I have copied the piece of the code, for your reference.
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    DECLARE
    v_uom_sys_selection NUMBER;
    v_curr_uom_sys VARCHAR2 (50);
    v_uom_num NUMBER;
    BEGIN
    v_uom_sys_selection := to_number(&uom);
    v_curr_uom_sys := EG.GET_CURRENT_UOM();
    v_uom_num := eg.get_user_selected_uomnum(v_curr_uom_sys);
    &&uom := to_char(v_uom_num);
    dbms_output.put_line('v_uom_num = ' || v_uom_num);
    dbms_output.put_line('&&uom = ' || &&uom);
    END;
    --prompt "&&uom"
    start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql
    Below are the results I get when commenting out the &&uom := to_char(v_uom_num); line. NOTE: the "value" of &&uom = 0.
    v_uom_num = 1
    0 = 0
    If I leave that line in, I get the following error:
    PLS-00103: Encountered the symbol "0" when expecting one of the following:
    begin case declare end exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "<an identifier> was inserted before "0" to continue.
    Message was edited by:
    user449676

  • Human task jsp customization assign calculated value problem...

    We customize human task jsp and add some field.
    We want assign a calculation result to a task variable...
    autogenerated HTML inbup box name is slns0_cl_task_sl_ns0_cl_payload_sl_ns1_cl_bim_Myprocessname_myparametername..
    is it possible to assign a value using this name ? is it correct way?
    is there any other way yo do it..
    Thanks...

    Thansk..
    I tried to use javascript. but I need ro add a combobox to the payload body jsp page.
    Because buid-in Oracle SOA procedures try to forward all parameters "object doesn't support this property error occurs..."
    So question is ...
    How can I add a combobox on payload body jsp pages ?
    Thaks..

  • How to assign a value to ODI Variable using ODI Procedure

    Hi ,
    Is it possible to assign a value to a ODI Variable using ODI Procedure ?
    If it is possible how we can do that.
    BEGIN
    IF #Counter=1
    Then
    #Next_Increment:=#Counter+1;
    End if;
    END;
    In my example I have 2 ODI Variables #counter and #Next_increment.
    I am trying to assign VALUE TO A ODI VARIABLE #next_increment from another ODI Variable #counter.
    thanks
    prasanna

    Prasanna,
    I have a similar requirement where I need to assign values to ODI variables within a procedure. How do we make use of an ODI package to accomplish this ?
    Actually, I have a sequence of ODI steps, and there is a call to a procedure 'LOG ERROR' from every step which gets called in case error occurs in any step. I just need to identify from which step the error came.
    Please help.

  • Is it possible to assign a default value to an out parameter??

    Is it possible to assign a default value to an out parameter??
    Thanks in advance.

    pradeep.vupala wrote:
    I think ur looking for an IN OUT parameter?That won't help.
    A quick test is easy to check what happens :
    SQL> create or replace procedure myproc(p_out out number default 1)
      2  as
      3  begin
      4  null;
      5  end;
      6  /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE MYPROC:
    LINE/COL ERROR
    1/18     PLS-00230: OUT and IN OUT formal parameters may not have default expressions
    SQL> create or replace procedure myproc(p_out in out number default 1)
      2  as
      3  begin
      4  null;
      5  end;
      6  /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE MYPROC:
    LINE/COL ERROR
    1/18     PLS-00230: OUT and IN OUT formal parameters may not have default expressions
    SQL>

  • It is possible to assign value range to non key fields in the table?

    Hi,
    I want to give some range of values to the fields which are non key fields in the table.
    is it possible?
    can anybody tell me the procedure.
    Thanks in Advance,
    venkat

    HI,
    It is higjly possible in case of Z-table. but in standard table you can't make any modification.
    You assign the value range to the domain of field.
    go to SE11 and open the database table.
    Select the Data Element of the fieldto which  you want assign the range.
    Click on its domain .
    click on Value Range tab.
    Set the range.
    Regards,
    anirban

  • Assigning a value to a parameter.

    Hi all,
    I am using CR XI, developping a report built upon a query in BW (using SAP Kit). The query in BW has a parameter PARAM1 of type string that comes automatically into my report but the type or the parameter is greyed. I can't change it.
    In reality, I am expecting a date to be entered. It would be more user friendly to offer the user the calendar interface to select a value rather than the textbox for a string.
    I can create a second parameter PARAM2 of type Date in CR, transform the input value to string but I do not know how to assign the result to PARAM1.
    I have tried an assignment in a formula using beforereadingreports but no luck.
    Does anybody know how to do this or if this is even possible ?
    Thanks.

    Thanks Graham - sorry it took me so long.
    That is an interesting suggestion that I did not think of. I tried but for some reason the parameter for the report against BW does not show up in the link part of the subreport definition. I created a "fake" main report with a date type parameter, a formula to translate it to a string but no way to "assign" its value to the parameter in the original report.
    Queries against SAP seem to have "specificities"...
    In other words, i am still stuck !

  • Can we assign two values to the same parameter? If yes how? For details ple

    Can we assign two values to the same parameter? If yes how? For details please go through the following SAP related program.
    Here I need to print 2 queries using the same parameter "QUERY" the value assigned to this parameter(query) is REPORT_TEST1. I want to assign one more value to this Parameter. Is is possible? This question may sound stupid if it is not possible please kindly reply.
    I want to do this to print two documents(values) with a single command (parameter)
    Anybody please help quickly,
    Now, I have 2 tables from different queries. I have a print (HTML written) option in my WEB Template
    JAVA PROGRAM:
    <param name="QUERY" value="REPORT_TEST1"/>
    function PrintReport(typePaper) {
    document.title ='Report';
    if (typePaper == "0")
    {var CurrentReportName = '&?mp=U&ptot=1&rtot=0&psize=' + escape(typePaper) + '&fsize=' + escape('39') + '&qtitle=' + escape(document.title);};
    if (typePaper == "1")
    {var CurrentReportName = '&?mp=U&ptot=1&rtot=0&psize=' + escape(typePaper) + '&fsize=' + escape('52') + '&qtitle=' + escape(document.title);};
    CurrentReportName += '&ASOFDATE=' + escape(AsOfLabel.innerText);
    var openCMD='<SAP_BW_URL>';
    openCMD += '&DATA_PROVIDER=REPORT_TEST1&TEMPLATE_ID=DPW_PRINT_PAGE&CMD=RELEASE_DATA_PROVIDER';
    openCMD += CurrentReportName;
    openWindow(openCMD,'MainTitleNow',800,600);
    The data provider here is REPORT_TEST1. Now it only prints the corresponding data for the data proviedr 1 i.e., REPORT_TEST1. I have a second table whose data comes from the data provider 2 when i use this HTML to print I want the second table contents from the data provider 2 (REPORT_TEST2)also to be printed simlutaneously.
    Please help.
    THANX A LOT,
    SRINI

    Hi,
    Try assigning two values seperated by a delimiter ( say '|') to the same parameter.
    In the function get the parameter value and seperate the values using the same delimiter.
    <param name="QUERY" value="REPORT_TEST1|REPORT_TEST2"/>
    Regards,
    Uma

  • Can we assign two values to the same parameter? If yes how?

    Can we assign two values to the same parameter? If yes how? For details please go through the following SAP related program.
    Here I need to print 2 queries using the same parameter "QUERY" the value assigned to this parameter(query) is REPORT_TEST1. I want to assign one more value to this Parameter. Is is possible? This question may sound stupid if it is not possible please kindly reply.
    I want to do this to print two documents(values) with a single command (parameter)
    Anybody please help quickly,
    Now, I have 2 tables from different queries. I have a print (HTML written) option in my WEB Template
    JAVA PROGRAM:
    <param name="QUERY" value="REPORT_TEST1"/>
    function PrintReport(typePaper) {
    document.title ='Report';
    if (typePaper == "0")
    {var CurrentReportName = '&?mp=U&ptot=1&rtot=0&psize=' + escape(typePaper) + '&fsize=' + escape('39') + '&qtitle=' + escape(document.title);};
    if (typePaper == "1")
    {var CurrentReportName = '&?mp=U&ptot=1&rtot=0&psize=' + escape(typePaper) + '&fsize=' + escape('52') + '&qtitle=' + escape(document.title);};
    CurrentReportName += '&ASOFDATE=' + escape(AsOfLabel.innerText);
    var openCMD='<SAP_BW_URL>';
    openCMD += '&DATA_PROVIDER=REPORT_TEST1&TEMPLATE_ID=DPW_PRINT_PAGE&CMD=RELEASE_DATA_PROVIDER';
    openCMD += CurrentReportName;
    openWindow(openCMD,'MainTitleNow',800,600);
    The data provider here is REPORT_TEST1. Now it only prints the corresponding data for the data proviedr 1 i.e., REPORT_TEST1. I have a second table whose data comes from the data provider 2 when i use this HTML to print I want the second table contents from the data provider 2 (REPORT_TEST2)also to be printed simlutaneously.
    Please help.
    THANX A LOT,
    SRINI

    Hi,
    Try assigning two values seperated by a delimiter ( say '|') to the same parameter.
    In the function get the parameter value and seperate the values using the same delimiter.
    <param name="QUERY" value="REPORT_TEST1|REPORT_TEST2"/>
    Regards,
    Uma

  • Assigning return value of a javascript function to a variable

    hi.
    I have a javascript function which returns string.
    I wanna assing return value of that function to variable.
    for example:
    <script>
    funtion writeMe()
    var ex;
    ex="try"
    return ex;
    </script>
    Then in body of JSP page. I wanna do something like:
    <% String st;%>
    Now I wanna assign the value that returned from writeMe function ("try") to st string.like:
    <%st= writeMe();%>. but of course it doesn't work. how can I do that?

    thnx. but actually what I want to do is sending some values produced by javascript to a barchart object. is it impossible too?
    I mean my script function returns something like "100, 200, 300". I wanna pass that values to barchart. when I want to add aplet tag to jsp code instead of writing:
    <param name="s1_value" value="100,200,300">
    I want to write somethin like:
    <param name="s1_value" value="myscriptfunction()">
    is it possible in JSP? I saw an example like this in asp. it was like:
    <param name="sampleLabels" value="<%call func1()>">. but in JSP it seems like call tag doesn't work. Is it possible in JSP?

  • Assigning a value to a constant in Calc Script

    Hi All,
    I'm trying to assign a value to a constant in a calc script, but not able to make it work.
    I need to get a user entered value from the database such as Indexation Value, and use that many times in my script. Rather than use:
    "member1"->"member2"->"member3"->"member4"->"member5"
    every time I access the value, I'd like to use:
    VAR IndexVal = "member1"->"member2"->"member3"->"member4"->"member5";
    and then use IndexVal in the script.
    Is this possible?, or do I have to use a substitution variable?
    Thanks.

    It is possible, but the variable and the calculations that use it must exist in the same Calc Bloack statement (Beginning and ending in parens)

  • Assign a value to class variable

    I want to define a class variable in class. And I want all subclasses of that class ot have a different value for that class variable. How can I do that?
    public class BaseClass {
      public static String tableName = "";
    }Now if I have a ClassA and I want to assign a value like this :
    public class ClassA extends BaseClass {
      tableName = "location";
    } I got an error message.
    I can move it in a static initializer block but then it will only work when the class is loaded. In my case its possible i want to get this value without loading the class.
    Ditto if i move it to constructor.
    Any input? Thanks

    Are you saying that if i have 2 classes ClassA and
    ClassB inherited from BaseClass, then both are
    sharing the same copy of 'tableName' staticvariable?
    If yes then I should go with an instance variable.No, I am saying that you can easily declare a
    tablName in A and another tableName in B.
    A.tableName will be shared between all the instances
    s of A. B.tableName will be shared between all the
    instances of B. And BaseClass.tableName is
    irelevant. I think you try to use
    BaseClass.tableName as some kind of template for
    sub-classes, but this does not happen: you need to
    declare tableName again and again in each subclass.
    IThanks for clarifying. Each class needs to have a variable "tableName" and it needs to have one copy of this variable for all of that class's objects. 2 classes will not have the same value of this tableName variable.
    Thats why I was defining it as static variable. And I define it in BaseClass so that I dont have to define it again in each subclass.
    Is there any better way? Thanks

  • Possibility to assign a color profile in the color management tab for more video formats

    Presently, in After Effects CS5, in the color management tab of the "Interpret Footage" dialog box the possibility to assign a color profile to footage is grayed out for many video formats.
    Formats that allow to assign a color profile include Quicktime/JPEG2000, Quicktime/Motion JPEG A, Quicktime/Motion JPEG B, Quicktime/MPEG-4, Quicktime/Animation as well as various image sequences, like tiff-sequences. (Motion JPEG A,B and Quicktime/MPEG-4 are not very helpful in this context because they have a small color shift when reimported to After Effects.)
    Formats that do not allow to assign a color profile include Quicktime/PhotoJPEG, Quicktime/H264, H264 main concept, DVCPRO HD 1080p30, F4V. (Here, H264 main concept has anyway the disadvantage that it has a color shift when reimported into After Effects.)
    In After Effects CS4 it was possible to assign a color profile to Quicktime/H264, Quicktime/PhotoJPEG, DVCPRO HD 1080p30, but in CS5 this is no longer possible.
    Those video formats that do not allow to assign a color profile automatically are interpreted as having the color profile HDTV (Rec. 709) Y'CbCr in case that the videos have 1920x1080 format; similar applies to PAL formats which get SDTV (Rec. 709) Y'CbCr color profile.
    (I did not find anything of this automatic assignment to HDTV or SDTV color profile in the "interpretation rules.txt" file, therefore it must be written into the programme itself.)
    With growing popularity of wide gamut monitors it becomes necessary to produce footage and other videos that have a color profile different from HDTV or sRGB. When such footage is reimported to After Effects it has the wrong color and the only workarounds are either to use (in After Effects) the effect "Color profile converter" which necessitates extra render time or to use somewhat unpopular formats, like JPEG2000 that has very large filesize.
    Presently many footage is produced in Quicktime/PhotoJPEG and therefore it would be very desirable to allow to assign a color profile to such footage in the color management tab of the "Interpret Footage" dialog box.
    Does anyone know why in AE CS5 the video formats Quicktime/PhotoJPEG and Quicktime/H264 do not allow to have an arbitrary color profile assigned (although it was possible in CS4), is it a bug, or does it have a deeper reason.
    In this context I have a related question, often I read that Quicktime videos have a gamma tag. Does this mean that part of the color profile (the gamma value) is actually embedded/remembered, like you have it for images where the gamma is part the embedded color profile.
    I use AE CS5 on Mac Pro 2009 with OS 10.6.7.
    Thanks,
    Volker

    Thank you Rick for this interesting explanations and the links to articles.
    In the past few days I performed a few tests in After Effects and it is interesting that you mention that cameras, like the Sony EX3, allow videos to have embedded color profiles. I am not working myself with cameras but either get footage from the internet or sometimes videos from our video department which produces videos with professional SONY cameras, usually I get them in a matrox mxf format.
    As far as my test with After Effects show it is not possible to embed color profiles in the videos rendered with After Effects. Independent of the color profile in the working space and independent from the color profile in the output module I always get the same reaction if I reimport videos rendered by After Effects back to After Effects:
    In AE CS5 videos made in the formats Quicktime/PhotoJPEG, Quicktime/H264, H264 main concept, DVCPRO HD 1080p30, F4V  are always interpreted as color profile SDTV/HDTV (Rec. 709) Y'CbCr (even if I made them in other color profiles, such as Adobe RGB, Photo RGB, sRGB); and there is no possibility to change this interpretation rule.
    In contrast videos made in the formats Quicktime/JPEG2000, Quicktime/Motion JPEG A, Quicktime/Motion JPEG B, Quicktime/MPEG-4, Quicktime/Animation are always interpreted as sRGB (even if if I made them in other color profiles, such as Adobe RGB, Photo RGB, HDTV); only this time I can change the interpretation rule. Therefore if I know for example that if I had selected Photo RGB in the Output module I can change after the reimport the interpretation rule from sRGB to Photo RGB and only then I get again the original colors.
    The only exceptions are picture sequences, such as tiff-sequences, where the original color profile is automatically selected in the interpretation of the footage.
    Therefore, unfortunately for videos produced by After Effects your advice "If it says something like sRGB and you can change it, in most cases you shouldn't change it because the guess is probably right. If there is no color profile assigned then you should assume that is correct." is not so easy to be applied. You have to know how you did it originally in the Output module and hope that you can change it to the proper color profile, in case that the original color profile in the Output module was different from sRGB and HDTV/SDTV. But it is interesting to hear from you that with cameras there seem to be more possibilities.
    For this reason it would be nice if in future versions of After Effects one could change the color profile in the the color management tab of the "Interpret Footage" dialog box also for formats such as Quicktime/PhotoJPEG, Quicktime/H264, H264 main concept, DVCPRO HD 1080p30, F4V.
    Of course one can always circumvent shortcomings by using tiff-sequences, QT/jpeg2000, or QT/Animation as formats for storing, which is anyway better for lossless or nearly lossless storing, but the files are then too large and also cannot be played easily with a player.
    Volker

  • I want to assign the value of a Javascript variable to JSP Variable

    I want to assign the value of a Javascript variable to JSP Variable .. for example :
    <%
    Bla Bla Bla
    %>
    <script>
    var JavaScriptVariable="hello"
    </script>
    <%
    String JSPVariable=// The Value of JavaScriptVariable ;
    %>
    How can i do that ??
    Thanks

    >I want to assign the value of a Javascript variable to JSP Variable
    cannot be done.Friend try to understand concepts properly Javascript is always excuted by the browser @clientside where as JSPCode is executed Websever(ServletContainer) @serverside.Through you are combining JSP Code blocks(Tags,Expressions,scriptlets...) & javascript under a single page webserver can only identify what is their under JSP Code blocks.
    Hope this could be an appropriate answer for your question.
    However,you can as well submit a request by encoding your URL with request parameters and the submit to the page and then collect it using request.getParameter(name).
    But under a single context state it is not possible
    REGARDS,
    RaHuL

Maybe you are looking for