String index out of bounds.

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

[477 byte] By [Feroz_CGa] at [2007-11-27 9:53:25]
# 1
You will need to provide the code to get a solution.Post the FormsRefresher class code if you can.
_helloWorld_a at 2007-7-13 0:22:39 > top of Java-index,Java Essentials,Java Programming...
# 2

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);

[b] logFilename = fileName.substring(0,fileName.lastIndexOf(".")) + ".log";[/b]

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

Feroz_CGa at 2007-7-13 0:22:39 > top of Java-index,Java Essentials,Java Programming...
# 3
your error is probably in this line:logFilename = fileName.substring(0,fileName.lastIndexOf("."))What does fileName.lastIndexOf(".")return?Message was edited by: manuel.leiria
manuel.leiriaa at 2007-7-13 0:22:39 > top of Java-index,Java Essentials,Java Programming...
# 4
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 lineString filename = args[8];
Feroz_CGa at 2007-7-13 0:22:39 > top of Java-index,Java Essentials,Java Programming...
# 5

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.

SomeoneElsea at 2007-7-13 0:22:39 > top of Java-index,Java Essentials,Java Programming...
# 6
Now the first issue is resoved. That line was returning -3. Now i am getting another error Unsatisfied link error.
Feroz_CGa at 2007-7-13 0:22:39 > top of Java-index,Java Essentials,Java Programming...
# 7

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

Feroz_CGa at 2007-7-13 0:22:39 > top of Java-index,Java Essentials,Java Programming...
# 8

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[i]);

}

this will show your what args you are actually passing in to the main method.

~Tim

SomeoneElsea at 2007-7-13 0:22:39 > top of Java-index,Java Essentials,Java Programming...
# 9

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.

Feroz_CGa at 2007-7-13 0:22:40 > top of Java-index,Java Essentials,Java Programming...
# 10
Did you add the code as suggested by Tim?Also, to get rid of the unsatisfied link error use this VM Arg -Xverify:none//Examplejava -Xverify:none myclass
_helloWorld_a at 2007-7-13 0:22:40 > top of Java-index,Java Essentials,Java Programming...