aspose file tools*
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 Soft Skills 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
Author

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

Wasin Raktham
Greenhorn

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: com.sun.media.PlaybackEngine@f5da06[ com.sun.media.PlaybackEngine@f5da06 ] ( 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(VideoUtility.java:66)
at com.user.vidtojpg.VideoUtility.getAllImages(VideoUtility.java:94)
at com.user.vidtojpg.VideoUtility.getAllImages(VideoUtility.java:105)
at com.user.vidtojpg.VideoUtility.main(VideoUtility.java:113)



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

Then my code is :

Ulf Dittmer
Marshal

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

Joined: Oct 27, 2005
Posts: 19783
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40040
    
  28
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: http://aspose.com/file-tools
 
subject: Why I get java.lang.NullPointerException for grabing image.