Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: How do I get the name and path of the running jar file? Date: Sun, 11 Dec 2016 20:10:01 -0500 Organization: Aioe.org NNTP Server Lines: 29 Message-ID: References: <0564c643-106a-499a-833e-dffe34d1e915@googlegroups.com> NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:36083 On 12/9/2016 1:50 AM, Wayne wrote: > 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. > > I think you meant getResourceAsStream(); getResource returns a URL, > not an InputStream. Yes. Not: .getResource() but: .getResourceAsStream() or: .getResource().openStream() Arne