s4 is initialized in a try so if the StringIndexOutOfBoundsException is
thrown it won't be initialized. In the catch set it to something (even null
is fine) and you should be fine.

James Amos Nathaniel Stauffer

-----Original Message-----
From: Lambok Sianturi [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 9:47 PM
To: JDJList
Subject: [jdjlist] Re: jar updation prob.


Hi all...

I have piece of code like this..

  char charArray[] = { 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a','y'};
  byte byteArray[] = { (byte) 'n', (byte) 'e', (byte) 'w',
         (byte) ' ', (byte) 'y', (byte) 'e',
         (byte) 'a', (byte) 'r' };
  StringBuffer buffer;
  String s, s1, s2, s3, s4, s5, s6, s7, output;

  s = new String( "hello" );
  buffer =
   new StringBuffer( "Welcome to Java Programming" );
  // use the String constructor
  s1 = new String();
  s2 = new String( s );
  s3 = new String( charArray );
  try {
   s4 = new String( charArray, 6, 4 );
  }
  catch( StringIndexOutOfBoundsException ex ) {
   System.out.println( "out of exception" );
  }
  s5 = new String( byteArray, 4, 4 );
  s6 = new String( byteArray );
  s7 = new String( buffer );


  output = "s1 = " + s1 +
    "\ns2 = " + s2 +
    "\ns3 = " + s3 +
    "\ns4 = " + s4 +
    "\ns5 = " + s5 +
    "\ns6 = " + s6 +
    "\ns7 = " + s7;

When i try to compile this, an error "variable s4 might not have been
initialized" occurs.
Would someone like to explain me why?

Thankyou in advance.

::Lambok Sianturi::
PT. Multi Garmenjaya
Jl. Krawang No. 1
Bandung - Jawa Barat
Indonesia
Phone : 62 22 7272222
----- Original Message -----
From: "abhay" <[EMAIL PROTECTED]>
To: "JDJList" <[EMAIL PROTECTED]>
Sent: Wednesday, January 22, 2003 9:45 PM
Subject: [jdjlist] jar updation prob.


| Hi everybody,
|
| I'm using WSAD-5 for application developement. I dynamically create a
| jar file (say AAA.jar ) and
| want to update it frequently in our application. I also use this jar
| file in our classpath of application.
| This jar is supposed to contain all the property files needed for our
| application. Initially AAA.jar will
| contain some property files. As the transactions initiate, property
| files in this jar will be changed and
| updated.
|
| I create a jar file by using a ZipOutputStream, store it in my
| ../../temp folder by some xx.0456.tmp
| file name. Then I delete the existing jar file using file.delete() and
| then rename the temp file by invoking
| the file.renameTo() method. But i found that the file.delete() doesn't
| delete my original jar file (which is
| being used by our application).
|
| Even invoking the SecurityManager.checkDelete() method didnot throw  any
| exception (as the
| docs say) . I think that since AAA.jar is being used by our application
| ... WSAD must have
| locked it. (Another reason for this conclsion is that i cannot modify
| any of our jars manually while the
| application is running under WSAD). But if this is true then
| SecurityManager should have thrown an
| exception ...surprisingly ..it didn't.
|
| I'm a little confused ...If i'm logically correct .. please suggest me a
| solution or a workaround.
| If i'm not then please tell me  where am i wrong.
|
| Thanks in advance.
|
| regards
| abhay
|
|
|
| ____________________________________________________
| To change your JDJList options, please visit:
| http://www.sys-con.com/java/list.cfm
|
| Be respectful! Clean up your posts before replying
| ____________________________________________________
|
|
|



____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm

Be respectful! Clean up your posts before replying
____________________________________________________

____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm

Be respectful! Clean up your posts before replying
____________________________________________________

Reply via email to