🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #68

Re: Absolute Path where the main() resides

#68
From: Shankar Unni
Date: Wed, 30 Mar 2005 18:17
14 lines
1412 bytes
Eric Orilla wrote:

> I want to get the full path of the jar file containing my main() function

One of those trivia that I couldn't even Google for easily, so I bit 
back my automatic suggestion.

Answer:

  Class.getProtectionDomain().getCodeSource().getLocation()

Get the class object for your class, and call the above. You'll get a 
URL to the location. (Remember, classes and jars can also be loaded over 
the net..)
Technical Details
Message-ID: <424aed43$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <424a2688$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1089d0,cdf403c8c6df140e
X-Google-Attributes: gid1089d0,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 30 Mar 2005 10:17:39 -0800
From: Shankar Unni <shankarunni@netscape.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Thunderbird/1.0.2 Mnenhy/0.7
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.api
Subject: Re: Absolute Path where the main() resides
References: <424a2688$1@newsgroups.borland.com>
In-Reply-To: <424a2688$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 68.122.224.119
Message-ID: <424aed43$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1112206659 68.122.224.119 (30 Mar 2005 10:17:39 -0800)
Lines: 14
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail