Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Application Path

Reply
Thread Tools

Application Path

 
 
Roman
Guest
Posts: n/a
 
      12-17-2005
Hello,

could someone pleas tell me, how I find out from inside the program, in
what path it is installed?

The property user.dir returns only the working directory but this is not
necessary the path to the Application.

System.getenv(String) is deprecated.

Thank you for any answers in advance.

--
Gruesse Roman
 
Reply With Quote
 
 
 
 
Jean-Francois Briere
Guest
Posts: n/a
 
      12-17-2005
Try:
System.getProperty("java.home");
(then you could append bin/java -or- bin\java.exe -or- bin\javaw.exe)

Regards

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      12-17-2005
Roman wrote:

> could someone pleas tell me, how I find out from inside the program, in
> what path it is installed?


<http://www.physci.org/codes/javafaq.jsp#path>

--
Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      12-18-2005
On Sat, 17 Dec 2005 14:53:04 +0000, Roman <> wrote, quoted
or indirectly quoted someone who said :

>could someone pleas tell me, how I find out from inside the program, in
>what path it is installed?


There are several different meanings to that question. One of them is
where did a given class file come from. See
http://mindprod.com/jgloss/where.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Roman
Guest
Posts: n/a
 
      12-18-2005
Thanks to all who answered. I got it.

--
Gruesse Roman
 
Reply With Quote
 
David Segall
Guest
Posts: n/a
 
      12-18-2005
Roman <> wrote:

>Thanks to all who answered. I got it.

Could you post the code please?
 
Reply With Quote
 
Roman
Guest
Posts: n/a
 
      12-18-2005
David Segall wrote:
> Roman <> wrote:
>
>
>>Thanks to all who answered. I got it.

>
> Could you post the code please?


Here a stand-alone example:


import java.net.URL;

public class App {
public static void main(String[] args) {
App app = new App();
System.out.println(
(app.getClass().getResource("App.class")).getPath( )
);
}
}


--
Gruesse Roman
 
Reply With Quote
 
Roman
Guest
Posts: n/a
 
      12-18-2005
Roman wrote:
> David Segall wrote:
>
>> Roman <> wrote:
>>
>>
>>> Thanks to all who answered. I got it.

>>
>>
>> Could you post the code please?

>
>
> Here a stand-alone example:
>
>
> import java.net.URL;
>
> public class App {
> public static void main(String[] args) {
> App app = new App();
> System.out.println(
> (app.getClass().getResource("App.class")).getPath( )
> );
> }
> }
>
>


Of course you could replace "App.class" by

app.getClass().getName() + ".class"

--
Gruesse Roman
 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      12-18-2005
Roman <> wrote:
> Here a stand-alone example:
>
>
> import java.net.URL;
>
> public class App {
> public static void main(String[] args) {
> App app = new App();
> System.out.println(
> (app.getClass().getResource("App.class")).getPath( )
> );
> }
> }


This code doesn't work. Or rather, it only works if your application is
composed of loose class files, but obviously isn't (or, at least,
hopefully isn't!) the case when you deploy the application.

I wrote a very complete and detailed answer to this question some time
ago. It's temporarily available in Word format at the following rather
ugly URL:

> http://www.javamoderator.org/Java%20...sic%20Data.doc


--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
ricky.clarkson@gmail.com
Guest
Posts: n/a
 
      12-19-2005
No, System.getenv(String) is not deprecated.

http://java.sun.com/j2se/1.5.0/docs/...m.html#getenv()

Compare and contrast with
http://java.sun.com/j2se/1.4.2/docs/...m.html#getenv()

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Server.MapPath() croaking with "failed to map path", but path is legal awbacker@gmail.com ASP .Net 0 05-12-2005 10:50 PM
how to get application path? Is that my method in getting path wrong? James Java 2 12-07-2004 11:59 AM
Bizzare: Invalid path to Access mdb, path is good Keith-Earl ASP .Net 1 05-03-2004 03:25 PM
Tomcat returning 404 error when using additional path (/servlet/myServlet/extra/path/info) Mupota Muchelemba Java 1 02-04-2004 12:43 AM
how to get application path when the application start? haiwen ASP .Net Web Controls 1 01-28-2004 03:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57