File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Why I get java.lang.NullPointerException for grabing image.    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why I get java.lang.NullPointerException for grabing image.    " Watch "Why I get java.lang.NullPointerException for grabing image.    " New topic

Why I get java.lang.NullPointerException for grabing image.

Wasin Raktham

Joined: Jun 24, 2009
Posts: 9
Hello, I'm beginner for JMF. I tried to write a java class to create a image to review video file.

I found a code from internet but it doesn't work for me. Because When I run the code, it show me..

Fobs4JMF - Native shared library found
635.088First Position: 0, 80 Duration: 635088
Frame Rate: 25
Opening Thread[JMF thread:[ ] ( configureThread),9,system]
Fobs Java2DRenderer: setInputFormat
Fobs Java2DRenderer: setInputFormat
FobsVideoTrack: mapTimeToFrame
FobsVideoTrack: mapFrameToTime
Exception in thread "main" java.lang.NullPointerException
at com.user.vidtojpg.VideoUtility.getImageOfCurrentFrame(
at com.user.vidtojpg.VideoUtility.getAllImages(
at com.user.vidtojpg.VideoUtility.getAllImages(
at com.user.vidtojpg.VideoUtility.main(

What about Exception in thread "main" java.lang.NullPointerException? and How I fix it.

Then my code is :

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Which line is #66? Which object is null?
Rob Spoor

Joined: Oct 27, 2005
Posts: 20279

Either fpc is null, or fgc is null, or frameBuffer is null.

Finding sources of (NullPointer)Exceptions should be a base skill when programming in Java, so I'm moving this to Beginning Java.

How To Ask Questions How To Answer Questions
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46429
fgc.grabFrame() might be returning null.

The hard part of correcting an NPE is working out which object points to null. You will have to separate that block of code into separate lines, with one assignment on each, then print out the test.
I agree. Here's the link:
subject: Why I get java.lang.NullPointerException for grabing image.
It's not a secret anymore!