nullpointerexception

null pointer exception comparing two strings in java.

I got this error message and I'm not quite sure whats wrong: Exception in thread "main" java.lang.NullPointerException at Risk.runTeams(Risk.java:384) at Risk.blobRunner(Risk.java:220) at Risk.genRunner(Risk.java:207) at Risk.main(Risk.java:176) Here is the relevant bits of code (i will draw attention to the line numb...

How to get Details on NullPointerException in JSP?

I am getting a null pointer exception in jsp and I want to find out what line has the null variable so i can fix it. Is there any simple way to do this? The printStackTrace didn't seem to give me any relevant information. Stack Trace: java.lang.NullPointerException at org.apache.jsp.data.index2_jsp._jspService(index2_jsp.java:176)...

Android: Using onStart() method in Bluetooth application

Hello, I am getting a nullpointer exception when my onStart() method is called. Here is the breakdown of my Android app: Opening the app brings a user to the homescreen: The user is then presented with the first 6 icons to choose from. When the user presses the "Sugar" icon it takes them to the SugarTabActivity. The SugarTabActivit...

Find out what variable is throwing a NullPointerException programatically

I know I can find out if a variable is null in Java using these techniques: if (var==null) -> too much work try { ... } catch (NullPointerException e) { ...} -> it tells me what line is throwing the exception using the debugger -> by hand, too slow Consider this line of code: if (this.superSL.items.get(name).getSource().compareTo(VI...

NullPointerException Java help

Hello guys. I've been tearing my hair out the past few hours trying to solve this problem. Every time I click on a JButton which should open a JFrame(And it does), i get a stacktrace saying I have a null point exception at these bits of code: In class A i have: aButton.addActionListener(new ActionListener() { public void actionPerf...

ArrayList<String> NullPointerException

Am trying to solve a labyrinth by DFS, using adj List to represent the vertices and edges of the graph. In total there are 12 nodes (3 rows[A,B,C] * 4 cols[0,..,3]). My program starts by saving all the vertex labels (A0,..C3), so far so good, then checks the adjacent nodes, also no problems, if movement is possible, it proceeds to create...

Exception in setDrawingCache in Android 1.5?

Hi, I am developing an application where I am using setDrawingCache and then once I get the Bitmap I destroy the cache by using destroyDrawingCache(). The application has been developed with Android SDK 1.6. When testing the application in emulator with Android 1.5 the application throws NullPointerException when try to manipulate the ...

Why do I get a Null Pointer Exception?

I have this code: Manager manager = new Manager("Name"); MyWindowListener windowListener = new MyWindowListener(); manager.addWindowListener(windowListener); Eclipse writes that I have a NullPointerException in the last line. What can be the reason for that. I do have constructors in the Manager and MyWindowListener. If it's importa...

How do you find the exact variable of a null pointer exception?

I've been at this one for a bit now. I've got a null pointer exception so I'm guessing somethings not been initialized. AdminMessages.inbox1.setText(messageRsetArray[0]); That's my code where it's targetting. But I can't find what's inside. It hasn't been initialized. AdminMessages is a class which contains a JTextField called inbo...

Typcast a null pointer to char*

Suppose I have a char* elem that is supposed to hold a char**, such that elem[0] = char**, elem[1...m]= <more chars>. Is there a way I can put a null ptr within char* elem? When I try to set elem = NULL, it gives me a type error because NULL is an int. Any help would be greatly appreciated! ...

NullPointerException when trying to add an object to a PriorityQueue

i keep getting a null pointer exception when trying to add an object to a priority queue i initialize the queue: private PriorityQueue<NodeObject> nodes; and here i try to add to it: NodeObject childNode = new NodeObject(child, 1); nodes.add(childNode); why doesn't this work? i know my NodeObject is not null because i create it ri...

Is it possible that EDT violations cause NullPointerException in an external software?

I have a Java software that was recently integrated into another Java software (which I will call "external" software). We use listeners and call back mechanisms for "communication" between two softwares. Creators of the "external" software say that they get a NullPointerException because of some EDT violations in my code. Can it be the...

Android Position reset after Restart? -> Serious Problem

Hey mates, is it possible, that android cleares the last known location after a restart? Yesterday my code worked very fine, but today after rebooting my phone (AND emulator) it seems that the .getLastKnownLocation (see below) returns null, which leads to a nullPointerException... Can you confirm that? How can I avoid this problem? I'm d...

Java: ListA.addAll(ListB) fires NullPointerException?

The err part is Capitalized in the code, it also comes in foreaching. Because of the abstract list, it cannot be initialized, declaration is in a static field. The lists have the same type. import java.util.*; public class Test { public static final List<String> highPrio = Arrays.asList("*","/"); public static List<Str...

NPE annotation scenarios and static-analysis tools for Java

Here is a number of code snippets that can throw NullPointerException. 01: public void m1(@Nullable String text) { System.out.print(text.toLowerCase()); // <-- expect to be reported. } 02: private boolean _closed = false; public void m1(@Nullable String text) { if(_closed) return; System.out.print(text.toLowerCa...

powermock : ProcessBuilder redirectErrorStream giving nullPointerException

I am using powermock to mock some native command invocation using process builder. the strange thing is these test pass sometimes and fail sometimes giving a NPE. Is this a powermock issue or some gotcha in the program. the snippet of the class under test is.. public void method1(String jsonString, String filename) { try { ...

NullPointerException and the best way to deal with it

Note: This is homework/assignment feel not to answer if you don't want to. Ok after some search and reading these: http://stackoverflow.com/questions/425439/how-to-check-if-array-element-is-null-to-avoid-nullpointerexception-in-java http://stackoverflow.com/questions/963936/gracefully-avoiding-nullpointerexception-in-java http://c2.com...

if (str1 == null) when throws a NullPointerException

In java, Does the following line have a possibility (even 0.01%) to throw a NullPointerException?? public static void handleRequest(String str1){ if (str1 == null){ // this line throws NPE, how come !! is it a JDK1.5 bug!! return null; } // other staff } Actually I am falling some bug in the code and It says that the...

NullPointerException when generating RSA keys with BouncyCastle

public static void main(String[] args) throws Exception { RSAKeyPairGenerator rsaKeyPairGen = new RSAKeyPairGenerator(); AsymmetricCipherKeyPair keyPair = rsaKeyPairGen.generateKeyPair(); } the rsaKeyPairGen is not null, but the generateKeyPair() method is throwing NullPointerException. What may be wrong? Error message: java....

Is it a bad idea if equals(null) throws NullPointerException instead?

The contract of equals with regards to null, is as follows: For any non-null reference value x, x.equals(null) should return false. This is rather peculiar, because if o1 != null and o2 == null, then we have: o1.equals(o2) // returns false o2.equals(o1) // throws NullPointerException The fact that o2.equals(o1) throws NullPointe...