Hi Lambok,
The reason is that you are initialising the string s4 in a try
block. You have declared s4 as a String earlier on, but you have not given
it a value. When you run the code in the try block the compiler (JVM) see
that there is a possibility that the line :
s4 = new String( charArray, 6, 4 );
failed, and so s4 may not have been given a value, i.e. it has not been
initialised.
Replace the line :
String s, s1, s2, s3, s4, s5, s6, s7, output;
with the lines :
String s, s1, s2, s3, s4, s5, s6, s7, output;
s4 = null;
and it will eliminate this error.
In fact, it is good coding practise to initialise all objects in a
Java program.
Regards,
Fintan
-----Original Message-----
From: Lambok Sianturi [mailto:[EMAIL PROTECTED]]
Sent: 24 January 2003 03:47
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
____________________________________________________
* ** *** ** * ** *** ** * ** *** ** *
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed.
Any views or opinions presented are solely those of the author, and do not necessarily
represent those of ESB.
If you have received this email in error please notify the sender.
Although ESB scans e-mail and attachments for viruses, it does not guarantee
that either are virus-free and accepts no liability for any damage sustained
as a result of viruses.
* ** *** ** * ** *** ** * ** *** ** *
____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
Be respectful! Clean up your posts before replying
____________________________________________________