Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Wayne Newsgroups: comp.lang.java.programmer Subject: Re: How do I get the name and path of the running jar file? Date: Fri, 9 Dec 2016 01:50:07 -0500 Organization: A noiseless patient Spider Lines: 15 Message-ID: References: <0564c643-106a-499a-833e-dffe34d1e915@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 9 Dec 2016 06:48:47 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="4a847f29f93bbb98eca70facb6faae9d"; logging-data="18808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PvuI18csph/rbrV6fMyCGe4Y463qvY3w=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 In-Reply-To: Cancel-Lock: sha1:KQcQXmmbHFHhiO7JhiMzgENIu0g= Xref: csiph.com comp.lang.java.programmer:36073 On 12/6/2016 9:18 PM, Arne Vajhøj wrote: > ... > > InputStream is = MyClass.class.getClassLoader().getResource("mypackage/foobar.wav"); > > should give you a stream to the file. Both when everything is > in the file system and when everything is in the jar file. > > Arne I think you meant getResourceAsStream(); getResource returns a URL, not an InputStream. -- Wayne