Forum Stats

  • 3,874,160 Users
  • 2,266,675 Discussions
  • 7,911,745 Comments

Discussions

String index out of bounds.

807605
807605 Member Posts: 44,277
edited Jul 6, 2007 9:04AM in Java Programming
I am gettin this error when i run an application. i am new to java. Can anybody help me to resolve this issue?

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
at com.iflex.fcc.FormsRefresher.initialize(FormsRefresher.java:214)
at com.iflex.fcc.FormsRefresher.main(FormsRefresher.java:236)
Exception in thread "main" java.lang.UnsatisfiedLinkError: no ifjapi90 in java.l

Comments

  • 807605
    807605 Member Posts: 44,277
    You will need to provide the code to get a solution.

    Post the FormsRefresher class code if you can.
  • 807605
    807605 Member Posts: 44,277
    edited Jul 6, 2007 8:13AM
     try
          {   System.out.println("2");
              Properties props   = new Properties();
              File file          = new File(System.getProperty("user.home") + File.separator + configFileName);
              BufferedInputStream bis = new BufferedInputStream(new FileInputStream (file));
              props.load(bis);
              if(bis != null)
                  bis.close();
    
              // Load the information from the properties file.
              String driver = (String)props.get("DB_DRIVER");
              String user    = (String)props.get("DB_USERNAME");
              String passwd  = (String)props.get("DB_PASSWORD");
              String url     = (String)props.get("DB_URL");
              conManager = ConnectionManager.getInstance(driver, user, passwd, url);
    
     <strong> logFilename = fileName.substring(0,fileName.lastIndexOf(".")) + ".log";</strong>
              System.out.println("log file name :: " + logFilename);
              fout = new FileOutputStream(new File(logFilename));
    
         }
         catch (Exception e)
         {
             e.printStackTrace();
         }
      }
      
      public static void main(String[] args)
      {
    
        FormsRefresher formsRefresher = new FormsRefresher();
        /**
        String filename = "D:\\FCC\\FMB\\CLDUDCMT.fmb";    
        String username ="BPELDEMO";
        String pwd = "BPELDEMO";
        String url = "jdbc:oracle:thin:@PLUTO:1521:seriousim";
       **/
        String filename = args[8];
        formsRefresher.initialize(filename);
        formsRefresher.processForm(filename);
      } 
    }
    I am getting the error in the lines quoted bold
    This is the code and i am getting another error also along with that.
    That is Unsatisfiedlink error

    Message was edited by:
    Feroz_CG
  • 800435
    800435 Member Posts: 825
    edited Jul 6, 2007 8:15AM
    your error is probably in this line:
    logFilename = fileName.substring(0,fileName.lastIndexOf("."))
    What does
    fileName.lastIndexOf(".")
    return?

    Message was edited by:
    manuel.leiria
  • 807605
    807605 Member Posts: 44,277
    Yes, i got it.....But i have given correct values to the string. Then why it is giving me that error. It is in the line which you have specified.
    Also in the below line
        String filename = args[8];
  • 807605
    807605 Member Posts: 44,277
    edited Jul 6, 2007 8:18AM
    the problem is most likely that there is not '.' in your fileName String, so this line return -1 for the lastIndexOf("."), and then when it trys to use that to get the substring it throws your error.
    logFilename = fileName.substring(0,fileName.lastIndexOf(".")) + ".log";
    put in a System.out.println for the fileName variable before this line to see what the actual value of that variable is.

    ~Tim

    EDIT: Too Slow Again.

    Print out the value of args[8] before your call to see what it is.
  • 807605
    807605 Member Posts: 44,277
    Now the first issue is resoved. That line was returning -3.
    Now i am getting another error Unsatisfied link error.
  • 807605
    807605 Member Posts: 44,277
    edited Jul 6, 2007 8:37AM
    Sorry ,I was wrong. That error is still there. String out of bounds exception error. It is not printing anything when i put a System.out.println() before that line and it directly throws that error.
    It is not responding to any message in that try block.

    Please Somebody help me!!!

    null
  • 807605
    807605 Member Posts: 44,277
    try sticking this code at the beginning of your main method.
    	int i = 0;
    	
    	//if you are using 1.5 or later
    	for(String arg : args)
    	{
    	    System.out.printf("Arg : %d\tValue: %s%n", i++, arg);
    	}
    	
    	//if you are using 1.4.2 or earlier
    	for(i = 0; i < args.length; i++ )
    	{
    	    System.out.println("Arg: " + i + "\tValue: " + args<em>);<br />
    	}<br />
    <br />
    <br />
    this will show your what args you are actually passing in to the main method.<br />
    <br />
    ~Tim </em>
  • 807605
    807605 Member Posts: 44,277
    D:\formsrefresh>java -jar formsrefresher.jar d:\work\cfintchg;
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(Unknown Source)
    at com.iflex.fcc.FormsRefresher.initialize(FormsRefresher.java:214)
    at com.iflex.fcc.FormsRefresher.main(FormsRefresher.java:236)
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no ifjapi90 in java.l
    ibrary.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at oracle.forms.jdapi.Jdapi.<clinit>(Unknown Source)
    at oracle.forms.jdapi.FormModule.open(Unknown Source)
    at oracle.forms.jdapi.FormModule.open(Unknown Source)
    at com.iflex.fcc.FormsRefresher.processForm(FormsRefresher.java:44)
    at com.iflex.fcc.FormsRefresher.main(FormsRefresher.java:237)

    I have done the same after my main method.I have compiled that java file and generated class file.
    the above statement is what i am getting.
  • 807605
    807605 Member Posts: 44,277
    edited Jul 6, 2007 9:04AM
    Did you add the code as suggested by Tim?

    Also, to get rid of the unsatisfied link error use this VM Arg
     -Xverify:none
    
    //Example
    
    java -Xverify:none myclass
This discussion has been closed.