tags:

views:

102

answers:

2

Hay Guy, I'm using org.apache.commons.net.nntp to connect to a nntp server, however running a simple nntp.connect(host, port) crashes the android.

Anyone got any ideas? Do java packages work with android straight out of the box? or do they need editing?

Thanks

+1  A: 

you haven't initialized the 'usenet' field, so you get a NullPointerException.

"NNTP usenet;" is equivalent to "NNTP usenet = null;".

Elliott Hughes
How do i initialize it? i thought putting usenet.connect("ssl-eu.astraweb.com", 563); would do that?
dotty
it's going to be something like: NTTP usenet = new NTTP();the documentation for that class, which you can read on the web, suggests you probably want NNTPClient instead, but the principle's the same.you probably need to read an introductory book on Java, specifically the bits about the difference between variables and instances.
Elliott Hughes
+1  A: 

You need to initialize your variable usenet, by just using NTTP usenet its called declaring the variable. It just declares the variable to type NTTP and it has a reference to nothing, which is commonly defined as being null, hence the NullPointerException.

You might need to check out NTTPClient instead, so add this into your code

NTTPClient usenet = new NTTPClient();

That is initializing the variable usenet to a NTTPClient.

Anthony Forloney