aspose file tools*
The moose likes Beginning Java and the fly likes Current diretory problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Current diretory problems" Watch "Current diretory problems" New topic
Author

Current diretory problems

Tim Manchester
Ranch Hand

Joined: Nov 03, 2004
Posts: 62
Howdy,

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?

Regards,

- Tim Manchester
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
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.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Tim Manchester
Ranch Hand

Joined: Nov 03, 2004
Posts: 62
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.

Regards,

- Tim Manchester
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970

YMMV


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Current diretory problems