Run TIme Error Message- Array Out of Bounds Exception

Good evening all,
I seem to have a run time error with the below segment of code. I've changed the (args[0]) a variety of ways but still get the same message.
I have a few questions regarding my methodology. First, am I headed down the right path (no spoonfeeding allowed please! I need to grasp and learn this myself). Second, would it be something causing error that is on another line and I'm not seeing it. Third, should I have added the entire class file?
public static void main(String [] args) throws IOException
   Inventory store = new Inventory ( 15);  // Sets store inventory
   Scanner inFile = new Scanner(new File(args [0])); // _Line 27 in the program_
   PrintWriter outfile = new PrintWriter(args [1]); 
   String temp; .
   double price; 
   int quantity; .
   inFile.next();
   int x = 0; Run time error received:
java.lang.ArrayIndexOutOfBoundsException: 0
     at StoreBusiness.main(StoreBusiness.java:27)
Thank you in advance everyone.

WarriorGeek wrote:
Thanks Flounder,
I feel pretty dumb after posting my answer.
I read the arrays tutorial and understand all that's described there but with what I've learned you have to start your array out at zero like I did. Should I use the variable name that I gave it in lieu of zero?No. The point is that since you didn't provide any arguments when you started your program, there is no arr[0] or arr[anything else]. It doesn't matter if you put an int literal between the brackets or a variable or a method that returns int. You can't access elements that don't exist.
So instead of java MyClass you need to do java MyClass something The "something" becomes args[0]. If you're using an IDE instead of the command line, there will be a place to configure what arguments you want to pass when you run your program.

Similar Messages

  • Run-time error '9': subscript out of range when starting Multisim/Utilboard v10

    Hi all!
    After having installed and registred NI Circuit Design Suite 10 (Single user licenses) on
    XP-SP2 and Windows2000-SP4 computer, I get the following error message when
    I try to start either Multisim10 or Utilboard10 (Full edition versions)
    "Run-time error '9':
    Subscript out of range
    The problem appears both with standard users as well as with the Administrator user.
    As I click on "OK", the program proceeds as usual and seems (?) to work fine.
    The problem does not appear if I do not register the copy of NI Circuit Design Suite 10
    and I run it as evaluation instead.
    Paolo Celani
    Attachments:
    error.jpg ‏29 KB

    Hi !
    We have german version of Window XP and 2000 (the folder where Multisim was installed is C:\Programme\ etc etc).
    The very same dialog box appears written in german (see attachment) in one of our computers, maybe because
    German was chosen as Standard language in Multisim during settings (I do not quite remember but I can find out).
    Thanks for helping me !
    Best regards
    Paolo Celani
    Attachments:
    error_de.JPG ‏33 KB

  • Run time error message when I try to open itunes?

    I cannot open itunes afte using it for 3 years.  I receive a run time error message. 

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    If you've already tried a complete uninstall and reinstall try opening iTunes in safe mode (hold down CTRL+SHIFT) as you start iTunes, then going to Edit > Preferences > Store and turing off Show iTunes in the Cloud purchases. You may find iTunes will now start normally.
    tt2

  • BIP Desktop Install Problem:  Run-time error '9' Subscript out of range

    Hi All,
    I am trying to get my BIP Desktop to work. I have notice previous threads regarding the internet explorer security patches affecting BIP Desktop and my problem is similar. Here is my problem:
    1. I installed BIP Desktop 5.7.146.
    2. I start Template Builder for Word Language by selecting Start>Programs>Oracle BI Publisher Desktop.
    3. A dialog box prompts for UI Language and I select English
    In the midst of the Template Builder for Word Language attempting to initiate/change the user interface language to English, it throws the following error:
    Run-time error '9' Subscript out of range
    Here are some details regarding my PC:
    XP sp2, MSXML6, jre1.5.0_15
    Also, my CPU performance hits it maximum while I am doing this
    Any thoughts on how to correct this?
    Thanks,
    Patrick

    Patrick,
    Were you able to find a solution to this problem?
    One of my colleagues is having the same issue.
    Regards,
    Srini

  • Iam getting run time error message when i try to open dream weaver cs4

    iam getting run time error message when i try to open dream weaver cs4

    exact message am getting when i try to open dreamweaver cs4- this application has requested the run time to terminate in it in an unusual  way . please contact the applications support team for more information.

  • Run-time error 9   subscript out of range in WAD open

    Hi All,
    When i open the WAD, I am getting the following error msg
    Run-time error 9
    Subscript out of range
    and it is killing the logon and screen.
    It is not happening to all the WAD, only for few of them,
    please give me the tips.
    Thanks
    Billy

    Thanks for the answer.
    I resolved it by replacing librfc.dll. There is a sap note to explain this issue.
    the reason for the problem is..
    If the web template has a bigger one then this problem is occurs.
    Thanks
    Billy

  • Array out of bounds exception when outputting array to file

    Could someone please tell me why i'm getting this array out of bounds exception?
    public class Assignment1 {
    public static void main(String[] names)throws IOException {
    BufferedReader keyboard = null;
    String userChoice;
    String inputFile = null;
    String studentData;
    String searchFile = null;
    String searchName;
    String stringIn;
    PrintWriter outputFile;
    FileWriter fWriter = null;
    BufferedReader fReader = null;
    int first;
    int last;
    int mid;
    int midValue;
    int i;
    int number;
    // creates keyboard as a buffered input stream
    keyboard = new BufferedReader(new InputStreamReader(System.in));
    //prompts user to choose 1 or 2 to make a corresponding choice
    System.out.println("Please Enter: ");
    System.out.println("1 to Create a File: ");
    System.out.println("2 to Search a File: ");
    userChoice = keyboard.readLine(); //user enters 1 or 2
    // converts a String into an int value
    number = Integer.parseInt(userChoice);
    fReader = new BufferedReader(new FileReader("studentData.txt"));
    if (number == 1) {          
    System.out.println("Please Enter the File Name to Create: ");
    studentData = keyboard.readLine();
    File file = new File("studentData.txt");
    fWriter = new FileWriter("studentData.txt");
    outputFile = new PrintWriter(fWriter);
    names = new String[200];
    i=0;
    //keep looping till sentinel
    while (studentData != "end" && studentData != null &&
    i < names.length) {
    if (studentData.equals("end")) break; //break and call sort
    System.out.println("Enter a name and press Enter. " +
    "Type 'end' and press Enter when done: ");
    studentData = keyboard.readLine();
    //loop for putting the names into the array
    for(i=0; i<names.length; i++) ;
    outputFile.println(names);
    } [b]outputFile.close();

    package assignment1;
    import java.io.*;
    import java.util.*;
    public class Assignment1 {
        public static void main(String[] names)throws IOException {
           BufferedReader keyboard = null;
           String userChoice;
           String inputFile = null;
           String studentData;
           String searchFile = null;
           String searchName;
           String stringIn;
           PrintWriter outputFile;
           FileWriter fWriter = null;
           BufferedReader fReader = null;
           int first;
           int last;
           int mid;
           int midValue;
           int i;
           int number;
           // creates keyboard as a buffered input stream
           keyboard = new BufferedReader(new InputStreamReader(System.in));
           //prompts user to choose 1 or 2 to make a corresponding choice
           System.out.println("Please Enter: ");
           System.out.println("1 to Create a File: ");
           System.out.println("2 to Search a File: ");
           userChoice = keyboard.readLine();    //user enters 1 or 2
           // converts a String into an int value
           number = Integer.parseInt(userChoice); 
           fReader = new BufferedReader(new FileReader("studentData.txt"));
           if (number == 1) {          
               System.out.println("Please Enter the File Name to Create: ");
               studentData = keyboard.readLine();
               File file = new File("studentData.txt");
               fWriter = new FileWriter("studentData.txt");
               outputFile = new PrintWriter(fWriter);
               names = new String[200];
               i=0;
                //keep looping till sentinel
                while (studentData.equals("end") && studentData != null &&
                       i < names.length) {
                   if (studentData.equals("end")) break;   //break and call sort
                   System.out.println("Enter a name and press Enter. " +
                                       "Type 'end' and press Enter when done: ");
                    studentData = keyboard.readLine();
                    //loop for putting the names into the array
                    for(i=0; i<names.length; i++) ;
                    outputFile.println(names);
    } outputFile.close();
    //call selectionSort() to order the array
         selectionSort(names);
         // Now output to a file.
    fWriter = new FileWriter("studentData.txt");
    outputFile = new PrintWriter(fWriter);
    } else if (number == 2) {
    System.out.println("Please Enter a File Name to search: ");
    searchFile = keyboard.readLine();
    inputFile = ("studentData.txt");
    } if (searchFile == "studentData.txt") {                      
    // Input from a file. See input file streams.
    fReader = new BufferedReader(new FileReader("studentData.txt"));
    System.out.println("Please enter a Name to search for: ");
    searchName = keyboard.readLine();
    //enter binary search code
    first = 0;
    last = 199;
    while (first < last)
    mid = (first + last)/2; // Compute mid point.
    if (searchName.compareTo(names[mid]) < 0) {
    last = mid; // repeat search in bottom half.
    } else if (searchName.compareTo(names[mid]) > 0) {
    first = mid + 1; // Repeat search in top half.
    } else {
    // Found it.
    System.out.println("The Name IS in the file.");
    } // did not find it.
    System.out.println("The Name IS NOT in the file.");
    } else //if userChoice != 1 or 2, re-prompt then start over
    System.out.println("Please Enter 1 or 2 or correctly " +
    "enter an existing file!!");
    // fWriter = new FileWriter("studentdata.txt");
    //outputFile = new PrintWriter(fWriter); //output
    public static void selectionSort(String[] names) {
    //use compareTo!!!!
    int smallIndex;
    int pass, j = 1, n = names.length;
    String temp;
    for (pass = 0; pass < n-1; pass++)
    //Code for Do/While Loop
    do {
    //scan the sublist starting at index pass
    smallIndex = pass;
    //jtraverses sublist names[pass+1] to names[n-1]
    for (j = pass+1; j < n; j++)
    //if smaller string found, smallIndex=that position
    if (names[j].compareTo(names[smallIndex]) < 0)
    smallIndex = j;
    temp = names[pass]; //swap
    names[pass] =names[smallIndex];
    names[smallIndex] = temp;
    } while (j <= names.length);
    //File file = new File("studentData.txt");
    This is the output window:
    init:
    deps-jar:
    compile:
    run:
    Please Enter:
    1 to Create a File:
    2 to Search a File:
    1
    Please Enter the File Name to Create:
    test
    Exception in thread "main" java.lang.NullPointerException
    at assignment1.Assignment1.selectionSort(Assignment1.java:134)
    at assignment1.Assignment1.main(Assignment1.java:73)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 9 seconds)

  • Migration from Access97 - Run time error message

    When I am trying to migrate from Access 97 to Oracle 8i Using Migration Work Bench I am getting the following error message.
    Microsoft Visual C++ Run Time Library (Message Title)
    Runtime Error
    Program: C:\ProgramFiles\Oracle\jre\1.1.7\JREW.EXE
    Abnormal Program Termination
    OK (button to click.)
    Please help me with your valuable input.
    null

    And is a boolean operator. Try it like this instead:
    Select Case ComboBox1.Text
    Case "Banks"
    Sector = "Bank"
    Index = -0.086
    Case "Mobile Telecommunications"
    Sector = "Mobile Telecommunications"
    Index = -0.024
    Case "Real Estate Investment Trusts"
    Sector = "Real Estate Investment Trusts"
    Index = 0.132
    End Select
    Still lost in code, just at a little higher level.

  • I cannot access my openoffice documents. I keep getting a run time error message

    When I try to open any OpenOffice.org 3.0 file I get a message that says Run time error! This application has asked the Run Time to terminate it in an unusual way.

    Please try updating to version 19.0
    Please check if all your plugins are up-to-date. To do this, go to the [http://mozilla.com/plugincheck Mozilla Plugin Check site].
    Once you're there, the site will check if all your plugins have the latest versions.
    If you see plugins in the list that have a yellow ''Update'' button or a red ''Update now'' button, please update these immediately.
    To do so, please click each red or yellow button. Then you should see a site that allows you to download the latest version. Double-click the downloaded file to start the installation and follow the steps mentioned in the installation procedure.

  • WAD run time error message

    Hi,
    I have problem opening template in WAD on my computer.  I will get the below error message every time i am trying to open a template.
    My WAD version is Release 2004s, Patch 700, Revision 172.
    Does anyone encounter the same problem before?
    [http://img2.freeimagehosting.net/uploads/5758023e39.jpg]

    >
    Claire Tan wrote:
    > Hi,
    >
    > Thanks for your help.
    >
    > I managed to get my WAD working after i installed 7 patches from SAP market place but i still have problem in WAD.
    >
    > When i click on a dropdown box in my WAD template, the properties panel on the left didn't refresh by itself.
    >
    > Has anyone encounter this problem before?
    >
    > I am currently on support package 17, patch 1, revision 452 for my WAD.
    >
    >
    > Thanks.
    Hi,
    Thanks for your prompt reply.
    I closed WAD and get it restarted twice and the problem above is solved.
    Here it comes another problem, when you click on execute button, it will pop up a page in Internet Explorer.
    I  managed to log into the portal but later got this javascript error:
    Line: 98
    Char: 7
    Error: Access is denied.
    Code:0
    URL: https://blahblahblah....my template name
    Do you have any idea what went wrong this time?
    I am running WAD version - BI AddOn 7.x(based on 6.40), support package 17, patch 1, revision 452
    My internet explorer version - 6.0.2900.2180.xpsp_sp2_qfe.070227-2300
    Thanks

  • LabVIEW 8.2 -- "unable to locate LabView run-time" error message

    I am trying to run a LabVIEW version 8 exe file and keep getting the
    "Unable to locate" error. I downloaded LabVIEW_8.2_Runtime_Engine.exe
    from the NI website and installed the entire contents of the
    distribution. After getting the error, I have tried uninstalling and
    reinstalling several times, with the same result.
    Is there some way I can troubleshoot this? Is there a configuration
    file or a registry entry I can check to see where LabVIEW is looking
    for the run-time?

    Michael,
    As Dennis said you need to make sure the version of the Runtime Engine matches the version of LabVIEW the executable was created with.
    You can find different versions of the Runtime Engine on our webpage here.
    Regards,
    Simon H
    Applications Engineer
    National Instruments

  • Custom run time error message into C# UI

    Hi,
    I'm trying to get the error message for the last step into my C# UI (using TestStand3.5).
    I've tryed the GetRunTimeErrorMessage in the UIMsg_Trace message event, but it doesn't work.
    Probably I should use the PostStepRunTimeError callback instead? Is there a sample code available in C# using it?  

    I'm getting the error code and the message, se below, but I also want to get the location info as in the standard TS error popup.
    The boolean Occurred parameter seems to be false even if I get an error. Is it reset to false or something? 
    int frameID = 0;
    errorCode = axExecutionViewMgrs[index].Thread.GetSequenceContext(0, out frameID).AsPropertyObject().GetValNumber("Parameters.ErrorLoad.Code", 0);
    details = axExecutionViewMgrs[index].Thread.GetSequenceContext(0, out frameID).AsPropertyObject().GetValString("Parameters.ErrorLoad.Msg", 0);
    location = axExecutionViewMgrs[index].Thread.GetSequenceContext(0, out frameID).AsPropertyObject().GetValBoolean("Parameters.ErrorLoad.Occurred", 0); 

  • I am getting a run time error message when I am trying to reinstall itunes and I'm not sure how to fix it. Can someone tell me what I need to do to get itunes back? Thanks!

    I'm not sure how or why this is happening and it has just started...I tried to update and then it would not allow me to open the file at all giving me a runtime error message and multiple windows (because of the help feature). It has been successfully reinstalled but I'm still getting the error message...what do I do?

    Hello, MommaLloyd24. 
    Thank you for visiting Apple Support Communities.
    Here are the steps I would recommend going through as they should resolve the issue.
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Cheers,
    Jason H.

  • Run time error message - Conversion from string "Mobile Telecommunications" to type 'Boolean' is not valid.

    I get a error message when I select an element in the combo box, please review my variables:
     Public Sector As String
        Public Index As Decimal
    ...and code
     Select Case ComboBox1.Text
                Case "Banks"
                    Sector = "Bank" And Index = -0.086
                Case "Mobile Telecommunications"
                    Sector = "Mobile Telecommunications" And Index = -0.024
                Case "Real Estate Investment Trusts"
                    Sector = "Real Estate Investment Trusts" And Index = 0.132
            End Select

    And is a boolean operator. Try it like this instead:
    Select Case ComboBox1.Text
    Case "Banks"
    Sector = "Bank"
    Index = -0.086
    Case "Mobile Telecommunications"
    Sector = "Mobile Telecommunications"
    Index = -0.024
    Case "Real Estate Investment Trusts"
    Sector = "Real Estate Investment Trusts"
    Index = 0.132
    End Select
    Still lost in code, just at a little higher level.

  • J2EE Deployment - Array Out of Bounds exception

    Hi,
    I have a problem with JDev 10.1.2 (1811). When I try and deploy a standard J2EE application (built using Struts / EJB, nothing particularly fancy) I get the error message:
    Target platform is Standard J2EE.
    java.lang.ArrayIndexOutOfBoundsException: 20086
         at oracle.ide.net.JarIndex.buildIndex(JarIndex.java:410)
         at oracle.ide.net.JarUtil.getJarIndex(JarUtil.java:197)
    (etc)The funny thing is, it was working right up until this morning. It's been in development for a couple of months now and it's been working fine. The only thing I did this morning is add in some input validation (i.e., add in one more class). It all compiles fine. One thing that did happen is, is deploy the WAR file by mistake, and then immediately try and deploy the EAR file from the same deployment profile. If the WAR file was still deploying, I don't know whether that would have messed anything up!
    Deployment works on another project though (in another workspace).
    anyone have any ideas?
    Thanks!
    Phill

    Ok, I feel rather stupid. I had two projects, 'Model' and 'ViewController'. I'd cleaned out the 'deploy' directory on the View Controller, but had forgotten to clean out the deploy directory on the 'Model' project. Clearing it out worked!
    Strange error message though.
    Thanks!

Maybe you are looking for

  • Problem in creating a new set using GS01

    Dear all, I am trying to create a set using Tcode - GSO1. But wehn try to create a SET with Basic Set it is asking for a ref table can you please help with some links about creating SETS. I want to create aset where we can maintian a list of Specific

  • [svn:osmf:] 14181: PARB changes: Move DateUtil to f4mClasses, it doesn' t need to be part of the public API.

    Revision: 14181 Revision: 14181 Author:   [email protected] Date:     2010-02-15 21:57:55 -0800 (Mon, 15 Feb 2010) Log Message: PARB changes: Move DateUtil to f4mClasses, it doesn't need to be part of the public API. Modified Paths:     osmf/trunk/fr

  • Error transport, when the DTP is implemented in Process chain

    Dear all, we are facing with a problem: when a DTP is already implemented in a process chain, the tranport of that depending transformation will get an error (return code 8) with message like this: "Start of the after-import method RS_TRFN_AFTER_IMPO

  • HT1386 How do I sync individual groups in the Contacts ap?

    I have synced my contacts from Outlook 2007 into my Iphone 5.  My Outlook categories appear as groups, but when I select one of the groups, choose "done" I do not have any contacts appearing.  The only time Contacts appear is when "All Contacts" is s

  • Please help download linux version

    I just bought a KOBO, and I'm told I need to install some adobe software to validate DRM. I have a Debian Wheezy O.S., I hope that that is not a problem. I just wanna read the books I bought. Thanks a lot!