473,725 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with "Exception in thread "main" java.lang.NullP ointerException "

2 New Member
hi,
i get Exception in thread "main" java.lang.NullP ointerException
when i run my application.
the exact error is:
"Exception in thread "main" java.lang.NullP ointerException
at sortmergejoin.M ergeJoin.Field( MergeJoin.java: 204)
at sortmergejoin.M ergeJoin.SMJoin (MergeJoin.java :84)
at sortmergejoin.M ergeJoin.<init> (MergeJoin.java :34)
at sortmergejoin.M ain.main(Main.j ava: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 7655
itsraghz
127 New Member
"Exception in thread "main" java.lang.NullP ointerException
at sortmergejoin.M ergeJoin.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 New Member
tanks for your reply.
the correct code part is:
public String Field(Frame frame,int lineNo){
String []recLine ;
String line;
line = Line(frame,line No);
recLine = line.split(" ");
return recLine[POSITION];
}

and i still get this error.
Nov 6 '08 #3
itsraghz
127 New Member
tanks for your reply.
the correct code part is:
public String Field(Frame frame,int lineNo){
String []recLine ;
String line;
line = Line(frame,line No);
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,line No) -- which you assign to "line". It is NULL and thats why you get a NullPointerExce ption 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
3005
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 webpage and installed it using SGI's swmgr application. The installation was very straight forward and there were no errors when I installed the package. Then I ran /usr/java2/bin/javac SelectSockets.java to make the SelectSockets.class file.
1
9117
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 version 1.4.0 and WMQ Series version 5.3 with CSD04. Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/mq/server/MQSESSION at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:67) at...
7
2765
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" java.lang.NoClassDefFoundError: I have several class files in the directory d:\personal\java-ChartGen Chart.class ChartColourScheme.class
12
7123
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" java.lang.NullPointerException at ticketSales.TicketSales.makeEvent(TicketSales.java:185) at ticketSales.TicketInput.main(TicketInput.java:56) Anyway I have several Class This one is called TransAction
6
32068
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 eclipse. I am compiling and running everything just fine. When I try to run my application on a commandline I get this error. I don't know why this is happening since it is working perfectly in eclipse. I am running a .bat file and here is the...
3
6441
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
3283
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 the following error Exception in thread "main" java.lang.NoClassDefFoundError: test Caused by: java.lang.ClassNotFoundException: test at java.net.URLClassLoader$1.run(Unknown Source) at...
4
14722
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 "appframework-1.0.3.jar;swing-worker-1.1.jar";CurrentStrobe.jar com.visionpro.currentstrobe.CurrentStrobeApp However, the statement below produces the error: java -cp "appframework-1.0.3.jar;swing-worker-1.1.jar" -jar CurrentStrobe.jar Exception in thread "main"...
1
6756
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 "main" java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1041) at java.awt.Container.add(Container.java:365) at orderingsystem.OrderingSystem.<init>(OrderingSystem.java:261) at...
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.