I mean that no matter what I try, it keeps returning null. With exactly the same code I have no problem on either a Win or a Linux system. I can't figure out how it works on the Mac and why it would be different.
Essentially, I have a "configuration" file for a class. For instance, if I have com.company.SomeClass, and bundled with it I have com.company.SomeClass.config, I am making a call such as:
SomeClass sc = new SomeClass(); InputStream is = sc.getClass().getResourceAsStream("/com/company/SomeClass.config");
Also tried the same thing in virtually every combination I could think of (using ClassLoader.getResourceAsStream, using the Mac file separator, omitting the leading slash... )
From that link, it looks like you are working with the old MacOS (9-), rather than OS X? The reason I conclude that is that the file separator on the old MacOS is ":", but on OS X it is "/" just like any other Unix. The JVM on the old MacOS is ancient, so I'm not surprised it doesn't support reflection well.
Originally posted by Bear Bibeault: I think that there may be confusion about what separator is being talked about.
Indeed, my apologies for my part in that. Returning to the issue at hand, I believe Dave has found a work-around, per his linked post. He says,
The Mac does not use the Sun implementation. I have no idea who makes it... Anyway, it doesn't work the same way.
Well, I can at least answer this one: Sun don't provide a Java implementation for OS X: they leave it to Apple. So I guess it's Apple who are responsible in this instance. I don't imagine for a minute they're going to provide more detail on how the classloader works, but you never know...
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
professionally read, modify and write PDF files from Java