473,396 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

help with "Exception in thread "main" java.lang.NullPointerException"

2
hi,
i get Exception in thread "main" java.lang.NullPointerException
when i run my application.
the exact error is:
"Exception in thread "main" java.lang.NullPointerException
at sortmergejoin.MergeJoin.Field(MergeJoin.java:204)
at sortmergejoin.MergeJoin.SMJoin(MergeJoin.java:84)
at sortmergejoin.MergeJoin.<init>(MergeJoin.java:34)
at sortmergejoin.Main.main(Main.java:24)
Java Result: 1"

it reffer to the MergeJoin class in:
Expand|Select|Wrap|Line Numbers
  1.  
  2.     /****** get line from the page frame ******/
  3.     public String  Line(Frame frame,int lineNo){
  4.         Page page = frame.getFrame();
  5.         String line = page.getLine(lineNo);     
  6.         //frame.Free();
  7.         return line;
  8.     }
  9.  
  10.     /******** get the Position Field *********/
  11.      public String  Field(Frame frame,int lineNo){
  12.         String []recLine=null;       
  13.         String line;
  14.         line = Line(frame,lineNo);
  15. //        recLine = line.split(" ");
  16.         return recLine[POSITION];
  17.     }
  18.  
can enyone help me ?
thanks.
Nov 6 '08 #1
3 7623
itsraghz
127 100+
"Exception in thread "main" java.lang.NullPointerException
at sortmergejoin.MergeJoin.Field(MergeJoin.java:204)
Look at the line #204 and the object what you are passing is NULL. that's why this error. Just initialize the object with a proper, non-null value and run it again.
Nov 6 '08 #2
ohadr
2
tanks for your reply.
the correct code part is:
public String Field(Frame frame,int lineNo){
String []recLine ;
String line;
line = Line(frame,lineNo);
recLine = line.split(" ");
return recLine[POSITION];
}

and i still get this error.
Nov 6 '08 #3
itsraghz
127 100+
tanks for your reply.
the correct code part is:
public String Field(Frame frame,int lineNo){
String []recLine ;
String line;
line = Line(frame,lineNo);
recLine = line.split(" ");
return recLine[POSITION];
}

and i still get this error.
That's fine. Use the "Code Tags" for the neat look and feel of Java code.

Expand|Select|Wrap|Line Numbers
  1. public String Field(Frame frame,int lineNo){
  2. String []recLine ;
  3. String line;
  4. line = Line(frame,lineNo);
  5. recLine = line.split(" ");
  6. return recLine[POSITION];
  7. }
What is the POSITION here? What exatly the Line(a,b) method returns here? I thought it was a Constructor but then I got to know you are NOT following the standards and you have the all the methods with the first letter capital (Line(), Field() etc.,).

Just check the return value of Line(frame,lineNo) -- which you assign to "line". It is NULL and thats why you get a NullPointerException in the next line when you invoke split() on it.
Nov 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phillip Montgomery | last post by:
Hello all; I'm trying to debug an issue with a java script called, SelectSockets. It appears to be a fairly common one found on the web. I downloaded the SGI Java v1.4.1 installation from SGI's...
1
by: Andy Howells | last post by:
Can anybody help me on this? I am getting the below error but have not got a clue why. The file in my classpath eing used has the class that it says is not defined. Any ideas? I am running java...
7
by: news | last post by:
I am pretty new to Java and I just install the JDK1.4.2 03 I am getting an error when I run the class file TestChart.class with the java.exe: Exception in thread "main"...
12
nomad
by: nomad | last post by:
Hi everyone; My Class has ended and I was not able to solve this problem in time, and I would still like to solve it. I got these error code. Exception in thread "main"...
6
by: nrperry | last post by:
Hello, I have a question about this error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -2 I am doing my java development in IBM Rationale...
3
by: Ananthu | last post by:
Hi This is my codings in order to access mysql database from java. Codings: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;
9
by: tiyaramunna | last post by:
I am trying to configure my system with Java program just to practice on the coding....when i compile a test.java program i am able to see the class file but i cant run the program ... I am getting...
4
by: jmitch89 | last post by:
I don't why I get this error: Exception in thread "main" java.lang.NoClassDefFoundError The statement below works just fine: java -cp...
1
by: onlinegear | last post by:
HI i am writing this for college i know i have loads of combo boxes with nothing in the i havent got that far yet. but every time i run this is comes up with this erro run: Exception in thread...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.