Article View: borland.public.jbuilder.java.swing
Article #9774Re: finding the application path
From: James Cook
Date: Tue, 25 Jan 2000 00:00
Date: Tue, 25 Jan 2000 00:00
45 lines
2274 bytes
2274 bytes
If your main program is fully qualified as:
com.mycompany.projectx.Main and this exists in the following directory:
c:\somedir\com\mycompany\projectx\Main.class
you would have your classpath set to "c:\somedir"
If you had a text file that exists in
c:\somedir\com\mycompany\projectx\text.txt you could read it in by referring
to it as:
this.class.getResourceAsStream("/com/mycompany/projectx/text.txt");
If you were in Main.class the class loader will use the classes package:
this.class.getResourceAsStream("text.txt");
jim
Alan Shiers <jshiers@istar.ca> wrote in message
news:388105F5.EB860769@istar.ca...
> Hi:
> I'm familiar with the File objects .path() and .getAbsolutePath()
> methods, but these methods don't allow me to obtain the applications
> path on the clients machine. In Visual Basic we have a method called
> App.path. When I use this method call as part of a string concatination
> App.path returns the path leading up to where the program sits on the
> clients computer.
> So, if myProgram is in C:\MSS\myProgram, App.path will return
> "C:\MSS\".
> This is how I would like to use App.path in java:
> String st = App.path() + "text.txt";
>
> Result: st would equal "C:\MSS\text.txt"
>
> I need a method like this for Java! App.path is a very convenient
> method, one that I use a great deal. I need to know, no matter where
> the client installs my java program, it will be able to find it's own
> application path within the directory structure it is in! Does anyone
> have just such a method I can use, or is there already one in existance
> in the API that I'm not aware of?
>
> Regards,
>
> Alan Shiers
>
Technical Details
Message-ID:
<388db036.0@news.dot.state.oh.us>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<388105F5.EB860769@istar.ca>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,c2ac60c7065ef2cf X-Google-Attributes: gid111d45,public From: "James Cook" <jimcook.spaminator@remove.for.spam.iname.com> Subject: Re: finding the application path Date: 2000/01/25 Message-ID: <388db036.0@news.dot.state.oh.us> X-Deja-AN: 577392142 References: <388105F5.EB860769@istar.ca> X-Trace: 25 Jan 2000 09:16:22 -0500, dotfw001-dmz.dot.state.oh.us X-MSMail-Priority: Normal X-Priority: 3 Newsgroups: borland.public.jbuilder.java.swing X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211