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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

GEtDocumentBase

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Image I = getImage(getCodeBase(), "1.gif");
Image I = getImage(getDocumentBase(), "1.gif");
both of these return a java.lang.NullPointerException WHY? The file is in the directory. What am I doint wrong??
Shawn
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shawn,
There is nothing wrong with either line, so there must be a problem either somewhere else in the code or in the location of the files.
Here is a little test:

and the html

Compile ImageLoader.java and put the resulting class file (ImageLoader.class), the html file, and your image file in the same directory. This should work. Then compare your code to it to see what is different.
If you still have problems, let us know.

[This message has been edited by Carl Trusiak (edited November 30, 2000).]
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic