Ekal,
pdfbox-1.0.0.jar is missing the "pdfbox.version"-Resource, which was
still available in pdfbox-0.8.0-incubating.jar, but is now missing. So
the "getVersion" returns, what the Resource-Loader returns: null.
This leads to the exception you are describing.
I am wondering, if this behaviour is ok. I think it is missleading and
can be traced down to a problem in the
org.apache.pdfsbox.util.ResourceLoader:
Beginning in Line 74:
---------------------
if( is == null )
{
File f = new File( resourceName );
if( f.exists() )
{
is = new FileInputStream( f );
}
}
IMHO there should be added an else-statment:
--------------------------------------------
if( is == null )
{
File f = new File( resourceName );
if( f.exists() )
{
is = new FileInputStream( f );
}
else
{
throw new IOException( "Error: could not find resource '" +
resourceName + "' on classpath." );
}
}
Perhaps it is a good idea to add a Boolean-Flag (boolean failIfNotFound)
like in the loadProperties-method, so that it is still possible to query
for the existence of a special Resource.
I put this for discussion into JIRA:
https://issues.apache.org/jira/browse/PDFBOX-652
Greetings,
Erik
--
My blog: http://blog.elitecoderz.net
Ekal Kulkarni wrote:
> I am using Eclipse IDE to develop my application. I added
pdfbox-1.0.0.jar
> as a library jar. But when I try to use any class, I get exception:
>
> code:
> public static void main(String[] args) {
> String mystr = org.apache.pdfbox.Version.getVersion();
> System.out.println(mystr);
> }
>
> Exception:
> Exception in thread "main" java.lang.NullPointerException
> at org.apache.pdfbox.Version.getVersion(Version.java:52)
> at Test1.main(Test1.java:10)
>
> I am a beginner in java. Please help how to solve this.
> -Ekal
>