Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #36057
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How do I get the name and path of the running jar file? |
| Date | 2016-12-06 16:07 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <o27987$d31$1@dont-email.me> (permalink) |
| References | <0564c643-106a-499a-833e-dffe34d1e915@googlegroups.com> |
On 12/6/2016 3:41 PM, triciac.1999.p@gmail.com wrote:
> I am writing a program that has sound files with type names and numbers like, "win1.wav" and "lose3.wav". I want the program to get the name and path of the running jar file so I can programmatically choose a random sound file of a specified type that is packaged inside the jar file without having to hardcode it myself. Everything I've tried works in Eclipse, but not after it is exported because it doesn't find the name of the jar file, only the path. Is there a way I can get the name AND path of the jar file? Could I search through the jar file packages without using the name and path?
Have you tried
String classPath = System.getProperty("java.class.path");
? For me, the class path *is* the path and name of the jar -- I guess
it might be more complicated if there are several jars involved, but
even then you could split the path on
System.getProperty("path.separator")
... and look through the jars one by one.
--
esosman@comcast-dot-net.invalid
"Nobody ever went broke underestimating the intelligence of the
American public." -- HLM (paraphrased)
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do I get the name and path of the running jar file? triciac.1999.p@gmail.com - 2016-12-06 12:41 -0800
Re: How do I get the name and path of the running jar file? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-12-06 16:07 -0500
Re: How do I get the name and path of the running jar file? Tricia Cahill <triciac.1999.p@gmail.com> - 2016-12-06 14:22 -0800
Re: How do I get the name and path of the running jar file? Arne Vajhøj <arne@vajhoej.dk> - 2016-12-06 21:18 -0500
Re: How do I get the name and path of the running jar file? Nigel Wade <nmw@local.domain> - 2016-12-08 13:20 +0000
Re: How do I get the name and path of the running jar file? Arne Vajhøj <arne@vajhoej.dk> - 2016-12-11 20:24 -0500
Re: How do I get the name and path of the running jar file? Nigel Wade <nmw@local.domain> - 2016-12-12 09:51 +0000
Re: How do I get the name and path of the running jar file? Arne Vajhøj <arne@vajhoej.dk> - 2016-12-12 20:25 -0500
Re: How do I get the name and path of the running jar file? Wayne <wayne@nospam.invalid> - 2016-12-09 01:50 -0500
Re: How do I get the name and path of the running jar file? Arne Vajhøj <arne@vajhoej.dk> - 2016-12-11 20:10 -0500
Re: How do I get the name and path of the running jar file? Silvio <silvio@internet.com> - 2016-12-07 22:06 +0100
Re: How do I get the name and path of the running jar file? lingmaaki@gmail.com - 2017-05-22 23:22 -0700
csiph-web