top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Error: java.lang.NullPointerException. Found when running jar file but its fine when running in IDE eclipse, Why?

0 votes
801 views

I run my code in Eclipse IDE and its fine. I have export it as jar file from Eclipse and run on terminal as jar file, it generates Error: java.lang.NullPointerException. Could not understand why is it so.

posted May 10, 2015 by Sudhakar Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

Making a guess -

manifest of the JAR file must contain a line of the form, something like
Main-Class: classname

Here, classname identifies the class having the public static void main(String[] args) method that serves as your application's starting point.

Also look at
http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html

answer May 10, 2015 by Salil Agrawal
Manifest file is fine.
Actually I am running MapReduce code which execute iteratively i.e. multiple times. I exported code as runnable jar form eclipse IDE. And run it as $ hadoop jar filename.jar . I used a public static variable in Mapper class want to use its value in subsequent iterations. NPE causes due to not getting this value in next iteration of job. How to persist a value in multiple classes ? Also I think in Eclipse only a single jvm is running but when running as jar file there will be multiple jvm.
Similar Questions
+2 votes

Did any one got these error before, please help

ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: xxxxx.com:50010:DataXceiver error processing WRITE_BLOCK operation  src: /xxxxxxxx:39000 dst: /xxxxxx:50010

java.lang.NullPointerException
at org.apache.hadoop.hdfs.server.datanode.BlockReceiver.(BlockReceiver.java:167)
at org.apache.hadoop.hdfs.server.datanode.DataXceiver.writeBlock(DataXceiver.java:604)
at org.apache.hadoop.hdfs.protocol.datatransfer.Receiver.opWriteBlock(Receiver.java:126)
at org.apache.hadoop.hdfs.protocol.datatransfer.Receiver.processOp(Receiver.java:72)
at org.apache.hadoop.hdfs.server.datanode.DataXceiver.run(DataXceiver.java:225)
at java.lang.Thread.run(Thread.java:745)
2015-01-11 04:13:21,846 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: IOException in offerService
WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Slow BlockReceiver write packet to mirror took 657ms (threshold=300ms)
+5 votes

I have used below code,

textareaA.addTextChangedListener(new TextWatcher() {
    @Override
    public void afterTextChanged(Editable arg0) {
    }

    @Override
    public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
    }

    @Override
    public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        double val = Double.parseDouble(textareaA.getText().toString());
        textareaB.setText(String.valueOf(val/10000));
    }      
});

textareaB.addTextChangedListener(new TextWatcher() {
    @Override
    public void afterTextChanged(Editable arg0) {
    }

    @Override
    public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
    }

    @Override
    public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        double val = Double.parseDouble(textareaB.getText().toString());
       textareaA.setText(String.valueOf(val*10000));
    }      
});

If I type a value in any EditTexts, it crashes and trows java.lang.StackOverflowError error.
Suggest a solution.

...