• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Directory / File not found

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I deployed a WAR file into Tomcat. This WAR file has a JAR file inside. Inside this JAR file, there is a directory structure: a directory called "mods" with a "fr" subdirectory.

So, the JAR file have something like this:

...
META-INF
mods
fr
...


The JAR file has a java class which tries to access the mods/fr directory:



Unfortunally, the directory is not found.

I have put the following lines to verify this:



=> it prints "C:\Programs\apache-tomcat-6.0.24\bin\mods\fr"



=> it prints "false" and "false".


What am I missing? how can I do for mods/fr directory to be found my the class of the JAR which is into the WAR file?

Thanks
Best regards

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Paulo. Are you trying to access a resource in that directory? In that case,

use this

or this

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A jar file is not a file system. You cannot use file I/O. As pointed out, you must obtain it as a resource.
 
Paulo Carvalho
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

Thanks for the answers.

In fact, what I want to do is to access the "mods/fr" directory which is in the JAR file and list all the files that ends with the "txt" extension.

So, resuming, I don't have the name of the ressource files, I just have the name of the directory where they are...

How can I list all the "txt" files present in the directory?

Thank you

Regards
 
Ogeh Ikem
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use this code to print the name of every file in a jar file.

You can implement a simple filter to print only the names of files in the "mods/fr" directory that end with the "txt" extension.

 
Paulo Carvalho
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the clue.
I will try it.

Best regards
 
reply
    Bookmark Topic Watch Topic
  • New Topic