Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #23065

Re: Getting path to jar passed on command line

X-Received by 10.224.131.193 with SMTP id y1mr648370qas.8.1363971437894; Fri, 22 Mar 2013 09:57:17 -0700 (PDT)
X-Received by 10.49.17.129 with SMTP id o1mr175625qed.9.1363971437876; Fri, 22 Mar 2013 09:57:17 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!ca1no1106403qab.0!news-out.google.com!k8ni11100qas.0!nntp.google.com!ca1no1106397qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.java.programmer
Date Fri, 22 Mar 2013 09:57:17 -0700 (PDT)
In-Reply-To <fdidnd_45PyGk9bMnZ2dnUVZ8kadnZ2d@bt.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=137.71.226.54; posting-account=iOAcbgoAAADC8J1iW-JMMSO74f5TboSg
NNTP-Posting-Host 137.71.226.54
References <98cfa140-0b4a-476a-bf1c-9cc2c39f22d8@googlegroups.com> <fdidnd_45PyGk9bMnZ2dnUVZ8kadnZ2d@bt.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <199c654e-c187-4885-aeac-ab6c38cb6b2c@googlegroups.com> (permalink)
Subject Re: Getting path to jar passed on command line
From raphfrk@gmail.com
Injection-Date Fri, 22 Mar 2013 16:57:17 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.java.programmer:23065

Show key headers only | View raw


On Thursday, March 21, 2013 1:41:46 PM UTC, lipska the kat wrote:
> On 21/03/13 10:55, raph...@gmail.com wrote:
> 
> > Is there a way to get the path of the jar file that was passed on the command line?
> 
> >
> 
> > java -jar<some path>
> 
> >
> 
> 
> 
> http://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file
> 
> 
> 
> Gives some good advice
> 
> 
> 
> The solution
> 
> 
> 
> String path = 
> 
> Test.class.getProtectionDomain().getCodeSource().getLocation().getPath();
> 
> 		String decodedPath = URLDecoder.decode(path, "UTF-8");
> 
> 
> 
> Works for me and gives me the path to the jar file containing the class 
> 
> that contains the above code.

Thanks for the info.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Getting path to jar passed on command line raphfrk@gmail.com - 2013-03-21 03:55 -0700
  Re: Getting path to jar passed on command line lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-21 12:37 +0000
    Re: Getting path to jar passed on command line Arne Vajhøj <arne@vajhoej.dk> - 2013-03-21 08:49 -0400
  Re: Getting path to jar passed on command line Arne Vajhøj <arne@vajhoej.dk> - 2013-03-21 08:55 -0400
  Re: Getting path to jar passed on command line lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-21 13:41 +0000
    Re: Getting path to jar passed on command line raphfrk@gmail.com - 2013-03-22 09:57 -0700
  Re: Getting path to jar passed on command line Roedy Green <see_website@mindprod.com.invalid> - 2013-03-21 14:11 -0700
    Re: Getting path to jar passed on command line Arne Vajhøj <arne@vajhoej.dk> - 2013-03-21 17:31 -0400

csiph-web