getResource can't find file???

T

Todd

Can someone tell me what I'm missing?

I have a .war file with the structure:

/WEB-INF
|
+-- classes
|
+ --- package name folder
| |
| + -- myClass.class
|
+ --- myProperties.properties

When I do a myClass.getResource("myProperties.properties") it is not
being found. I thought everything under the WEB-INF is on the
classpath, so I can't understand why. Can someone help?

TIA
 
A

Andrew Thompson

/WEB-INF
|
+-- classes ....
+ --- myProperties.properties

When I do a myClass.getResource("myProperties.properties")

Try..

myClass.getResource("/myProperties.properties")

HTH
 
R

Raymond DeCampo

Todd said:
Can someone tell me what I'm missing?

I have a .war file with the structure:

/WEB-INF
|
+-- classes
|
+ --- package name folder
| |
| + -- myClass.class
|
+ --- myProperties.properties

When I do a myClass.getResource("myProperties.properties") it is not
being found. I thought everything under the WEB-INF is on the
classpath, so I can't understand why. Can someone help?

Read the javadoc for java.lang.Class.getResource() carefully, especially
the second paragraph, especially the part about the package name.

Ray
 
R

Roedy Green

When I do a myClass.getResource("myProperties.properties") it is not
being found. I thought everything under the WEB-INF is on the
classpath, so I can't understand why. Can someone help?

getResource is just a thing to generate you an URL to the resource.

See http://mindprod.com/jgloss/images.html

for the many ways to get an image.

Once you understand that, you should be able to solve your problem.

You have to make sure your resource is where you think it is under the
correct membername.


Try signing your applet. The problem may be the resource is not
"downstream" of the web page.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
R

Raymond DeCampo

Roedy said:
getResource is just a thing to generate you an URL to the resource.

See http://mindprod.com/jgloss/images.html

for the many ways to get an image.

Once you understand that, you should be able to solve your problem.

You have to make sure your resource is where you think it is under the
correct membername.


Try signing your applet. The problem may be the resource is not
"downstream" of the web page.

Once again, it is not necessary to sign an applet to access resources
that are "downstream", as you say.

Ray
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top