privileges to get the resource

R

rikhardw

Hi, I have a problem with an applet. I am trying to load images from a
class that is not the main executing class of the applet, I am using
the following code
Component output_comp;
URL imgurl =
getClass().getClassLoader().getResource(("images/image1.gif"));
Image img = output_comp.getToolkit().createImage(imgurl);
The imgurl that is returned is null so I believe that this is due to
the caller not having adequate privileges to get the resource. Does
anyone know how to fix this problem or know what problem I have?
 
A

Andrew Thompson

URL imgurl =
getClass().getClassLoader().getResource(("images/image1.gif")); ...
The imgurl that is returned is null so I believe that this is due to
the caller not having adequate privileges to get the resource.

You believe wrong. If that were the case, the call would
throw a SecurityAccessException or similar.

The problem here is that the resource is simply not
being found.
..Does
anyone know how to fix this problem ...

We'll start with the usual..
1) URL (of your broken applet)?
...

Andrew T.
 
A

Andrew Thompson

(e-mail address removed) wrote:

As an aside...
URL imgurl =
getClass().getClassLoader().getResource(("images/image1.gif"));

//original
URL imgurl =
getClass().getClassLoader().getResource(("images/image1.gif"));
// 1st variant
URL imgurl1 =
getClass().getClassLoader().getResource("images/image1.gif");
// 2nd variant
URL imgurl2 =
getClass().getResource("images/image1.gif");

I suspect it will make no difference, but give each variant
a whirl, and report the results.

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top