This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm using Websphere and I've put together an enterprise app that includes a java project (DataAccess) and a struts web app. I created the java project because it's for utilities that I'll want to reuse so after I got that project mostly together, I exported a jar file from it into the lib directory of my web app.
Now in the Action class of one of my jsp's it instantiates a class out of the jar file just fine. The problem is that that class reads two files, neither of which it can find. I've moved those dang files all over both of my projects! The system error message doesn't tell me where it's trying to find the files (DANG!) but it does tell me it just can't find them.
If anyone can tell me, is there a system call that reports back what the current application thinks is the current directory? Or better still, does anyone know where I ought to put the files that a class in a jar would be looking for?
How are you trying to read those files? When inside of a JAR, or EAR, or WAR, or whateveR .. .. you need to use Classloader.getResourceAsStream(), or one of the other methods that it gives you. Once you're doing that, you're going to be just fine assuming your files are actually packaged correctly.
I wasn't bundling the files with the jar. I wanted to be able to use different files (one is a config file and the other has variable data). Though I will keep your earlier idea in mind for future use.