Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Current diretory problems

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Tim Manchester
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

YMMV
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic