Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

Posts: 9
  • Mark post as helpful
  • send pies
  • 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:[ ] ( 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 :

Posts: 43016
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which line is #66? Which object is null?
Posts: 21972
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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.
Posts: 69873
  • Mark post as helpful
  • send pies
  • 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.
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic