>>>> I want to know in which path is application.
>>>> Until now I use the following super_dumb code:
[quoted text clipped - 15 lines]
>
> What is the 'X'?
>> With the code above I have it. But code is a little bit confusing.
>
> So is your approach. There are very few end goals
> that require knowing the codebase that the application
> is using, and attempts to find that codebase often
> indicate poor (and fragile) design.
>O/H Andrew Thompson έγραψε:
>>>>> I want to know in which path is application.
...
>> What is the 'X'?
>
>you right.
>1. I want to open a "config.ini" file which is in JAR's path.
>2. I want to open an "index.html" which is in JAR's path.
That *still* does not quite come up to a statememnt
of a 'user feature', but it is close enough.
OK - *why* are these files in the Jar's path?
Who, or what, caused them to be there?
For example, some apps. are supplied as Zip
archives, with the instructions to 'unzip to a new
directory on your system' - that might be one way
these files all happen to be in the same place.
But is does not *have* to be that way.
You might write a simple 'unzipper - installer'
that puts the config.ini and index.html into
a *known* path, that can be easily found later,
while putting everything else in a single (hidden
or otherwise) directory.
Web start also offers mechanims to 'install'
files or do other such things at first application
start.
>>> With the code above I have it. But code is a little bit confusing.
..and 'fragile'. Every time devlopers seem to come
up with a 'rock solid' way to get the app. path, Sun
(seems to*) changes the rules. * They are really just
trying to design a robust and fast plug-in, but things
happen in that process that affect Java apps.

Signature
Andrew Thompson
http://www.athompson.info/andrew/
Chameleon - 21 Aug 2007 15:21 GMT
O/H Andrew Thompson έγραψε:
>> O/H Andrew Thompson έγραψε:
>>>>>> I want to know in which path is application.
[quoted text clipped - 6 lines]
> That *still* does not quite come up to a statememnt
> of a 'user feature', but it is close enough.
"config.ini" keeps the application's configuration (Settings dialog)
"index.html" is the file which load in browser as HELP with
"BrowserLauncher" class and it is outside the jar because not all
browsers support the "jar:http://......."
> OK - *why* are these files in the Jar's path?
> Who, or what, caused them to be there?
I want "config.ini" in the directory where I place the JAR file.
I want "index.html" and some other help files, outside the JAR file
because not all web browsers can open these files inside the JAR.
> For example, some apps. are supplied as Zip
> archives, with the instructions to 'unzip to a new
> directory on your system' - that might be one way
> these files all happen to be in the same place.
My application installation package is a zip file contains a JAR file
and some help files.
Or a JAR file only (forget about help).
> But is does not *have* to be that way.
> You might write a simple 'unzipper - installer'
> that puts the config.ini and index.html into
> a *known* path, that can be easily found later,
> while putting everything else in a single (hidden
> or otherwise) directory.
Yes. "config.ini" created inside directory which contains the JAR file
and "index.html" and other help files are placed in the same directory
plus "/help/"
> Web start also offers mechanims to 'install'
> files or do other such things at first application
> start.
I believe the problem is very easy.
>>>> With the code above I have it. But code is a little bit confusing.
>
[quoted text clipped - 3 lines]
> trying to design a robust and fast plug-in, but things
> happen in that process that affect Java apps.
the code works from version 1.4 to today. I don't know keyword "java"
before the version 1.4! I am newbie ;-)
Sorry for the "<present simple> *before* ..." and other related things.
My english sucks!
> O/H Andrew Thompson :
>
[quoted text clipped - 39 lines]
> rootPath = "";
> }
Ah, perhaps you should look into ClassLoader.getResource(), or
Class.getResource(). That is probably what you are really looking
for.