Application path

M

M K

How can I get a handle to where the application is installed or where all
the .java files are installed? I want to be able to install this app
anywhere and be able to retrieve the users application path so I can prepend
it to the name of the file.

Mark
 
A

Andrew Thompson

How can I get a handle to where the application is installed or where all
the .java files are installed?

..I want to be able to install this app
anywhere and be able to retrieve the users application path so I can prepend
it to the name of the file.

What file?
 
A

Andrew Thompson

And as an aside - it is a very strange Java application
that installs .java files on the end user's computer.
 
C

Chris Smith

M K said:
How can I get a handle to where the application is installed or where all
the .java files are installed? I want to be able to install this app
anywhere and be able to retrieve the users application path so I can prepend
it to the name of the file.

I've answered this question a number of times in the past. You can
search Google Groups for past articles on comp.lang.java.* from me
containing the word "CodeSource".

Or, I've written a draft of a more complete answer at the following URL.
Technique 5 is what you're asking for, but techniques 1 through 4 may
fit your needs as well and are better ideas if they are possible.

Also, comments on the article are appreciated, for those of you with the
desire to do so.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
M

M K

Thanks Chris, just what I was looking for.

Mark

Chris Smith said:
I've answered this question a number of times in the past. You can
search Google Groups for past articles on comp.lang.java.* from me
containing the word "CodeSource".

Or, I've written a draft of a more complete answer at the following URL.
Technique 5 is what you're asking for, but techniques 1 through 4 may
fit your needs as well and are better ideas if they are possible.
http://www.javamoderator.org/Java W...aneous/Finding Application Intrinsic Data.doc

Also, comments on the article are appreciated, for those of you with the
desire to do so.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
M

M K

After getting pointed in the right direction I can do it in 1 line

String temp = getClass().getResource("fileIamLookingFor.ext").toString();
 
?

=?iso-8859-1?q?Markus_B._Kr=FCger?=

Chris Smith said:
M K said:
How can I get a handle to where the application is installed or
where all the .java files are installed? [...]

[...] I've written a draft of a more complete answer at the
following URL. Technique 5 is what you're asking for, but
techniques 1 through 4 may fit your needs as well and are better
ideas if they are possible.

http://www.javamoderator.org/Java W...aneous/Finding Application Intrinsic Data.doc

Also, comments on the article are appreciated, for those of you with the
desire to do so.

Thank you for a useful survey of techniques. Since you also consider
servlets in your article, you may want to include the naming
environment (JNDI), as described in chapter SRV.9.11 of the servlet
specification (v2.4) and chapter J2EE.5 of the J2EE specification
(v1.4). See also <http://java.sun.com/blueprints/guidelines/
designing_enterprise_applications_2e/deployment/deployment5.html#1037411>.

The benefit of using the naming environment is that unlike servlet
context parameters and servlet context resources, it offers a way to
configure web applications without modifying the application itself.
This is practical when you are deploying WAR files, for instance.
Also, many servlet containers provide web interfaces for setting the
naming environment (e.g., Tomcat Admin), so that the application
deployers can see a list of available configuration options with
descriptions and modify them without needing to manually edit an XML
file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top