Launch by JAR and listing files in ZIP

K

Karsten Wutzke

Hi all!

1. Is there any reliable way to tell whether the current program was
launched via JAR file or locally via the class files? I need to list
files in JAR directories in the former case, if not launched via JAR
file, I want to list files in local dirs via File.listFiles. ... which
brings me to issue #2...

2. How do I list files in JAR/ZIP directories?

I'd like to go the same way as resources do, e.g.
this.getClass().getResource(relativePath) shall (at best) create a URL
object that points to the JAR resource directory when launched via
JAR. When launched via class files, the URL resource to the local
directory should be returned. This looks like a trivial thing to me,
but it is getting more complicated than I thought, because there is no
simple way of listing files for URL's (a respective listFiles is
missing).

Any tips on how to best solve this quickly and painlessly?

TIA
Karsten
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top