Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :

 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which line is #66? Which object is null?
 
Sheriff
Posts: 22563
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 74630
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic