Hi there,
I am using the WIN32 sun implementation from CLDC Version 1.1. I
compiled the simple helloworld.java but when i tried to open a serial
port i get the alert error. The exact code works fine on under a J2SE
VM running CDLC. I examined the Connection classes and it has a static
initialiser block. I then added the static initialiser block to the
helloworld and guess what?... it caused and alert!
import java.io.*;
import java.lang.*;
import javax.microedition.io.*;
public class hello
{
static {
Object obj =
System.getProperty("microedition.configuration");
if( obj == null ){
System.out.println( "static hello" + obj.toString());
}
}
public static void main(String[] args) {
System.out.println( "hello");
}
}
What is going on here?
any help appreciated.
-lucio
Gordon Beaton - 16 Jul 2003 04:03 GMT
> I am using the WIN32 sun implementation from CLDC Version 1.1. I
> compiled the simple helloworld.java but when i tried to open a
[quoted text clipped - 18 lines]
> }
> }
Don't call obj.toString() when obj is null! Probably you meant to do
this instead:
if (obj != null) {
System.out.println( "static hello" + obj.toString());
}
Of course your code will work fine when the property is found and obj
isn't null.
/gordon

Signature
[ do not send me private copies of your followups ]
g o r d o n . b e a t o n @ e r i c s s o n . c o m