How to get the path of remotly run application by knowing the port number

Discussion in 'Java' started by sundy.jk@gmail.com, Apr 4, 2005.

  1. Guest

    Hi,
    I am new to this group, and i request you all to help in solving the
    issues i have.
    Thank you for having this group.
    I need to know the path or install directory of an application,
    I am able to access the the application by port number.
    but i need to wright a java programe thr which i need to get the path
    or install directory of the application.
    Eg
    http://servername:2000/
    I request you all to help in the same.
    , Apr 4, 2005
    #1
    1. Advertising

  2. Hi,

    Sorry you can't do such thing.
    Any application may open ports, and knowing about open ports will never help
    you find
    where the application is ran from or installed in.

    Regards,

    Arnaud

    <> a écrit dans le message news:
    ...
    > Hi,
    > I am new to this group, and i request you all to help in solving the
    > issues i have.
    > Thank you for having this group.
    > I need to know the path or install directory of an application,
    > I am able to access the the application by port number.
    > but i need to wright a java programe thr which i need to get the path
    > or install directory of the application.
    > Eg
    > http://servername:2000/
    > I request you all to help in the same.
    >
    Arnaud Berger, Apr 4, 2005
    #2
    1. Advertising

  3. Yu SONG Guest

    Re: How to get the path of remotly run application by knowing theport number

    wrote:
    > Hi,
    > I am new to this group, and i request you all to help in solving the
    > issues i have.
    > Thank you for having this group.
    > I need to know the path or install directory of an application,
    > I am able to access the the application by port number.
    > but i need to wright a java programe thr which i need to get the path
    > or install directory of the application.
    > Eg
    > http://servername:2000/
    > I request you all to help in the same.
    >


    Whether telling you the internal path or not is decided by "the
    application" on the server.


    --
    Song

    /* E-mail.c */
    #define User "Yu.Song"
    #define At '@'
    #define Warwick "warwick.ac.uk"
    int main() {
    printf("Yu Song's E-mail: %s%c%s", User, At, Warwick);
    return 0;}

    Further Info. : http://www.dcs.warwick.ac.uk/~esubbn/
    _______________________________________________________
    Yu SONG, Apr 4, 2005
    #3
  4. John McGrath Guest

    On 4/4/2005 at 6:07:53 AM, wrote:

    > i need to wright a java programe thr which i need to get the path
    > or install directory of the application.


    Because of the way that Java loads classes, it is impossible to do this in
    the general case. Java classes are loaded by an instance of a subclass of
    ClassLoader. How the subclass loads the class is not specified. While
    the standard ClassLoaders load classes from a directory or a JAR file,
    others could load it from anywhere. You could even have a ClassLoader
    that writes the code on the fly.

    But while you cannot make this work for *all* cases, you may be able to
    make it work for all cases that matter to you. Assuming that your main
    program class is called Main, the following expression will give you a URL
    for the location it was loaded from:

    Main.class.getProtectionDomain().getCodeSource().getLocation();

    If your Main class is loaded from a JAR file, this will give you the URL
    for the JAR file itself. If your class is loaded from a directory, this
    will give you the root directory of the class tree.

    If you use this, do not design your application so that it is absolutely
    required - it may be that you cannot get the value. This is reasonable
    for choosing a default directory, but make sure there are alternate means
    of specifying directories. I understand that there are circumstances
    where you will have a null CodeSource, although I have never figured out
    how to cause that. And be certain to bullet-proof the code - test for
    null return values from all of these methods.

    --
    Regards,

    John McGrath
    John McGrath, Apr 5, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ray5531
    Replies:
    14
    Views:
    615
    Ray5531
    May 5, 2005
  2. jajoo

    get MBeanServer remotly

    jajoo, Nov 23, 2004, in forum: Java
    Replies:
    0
    Views:
    459
    jajoo
    Nov 23, 2004
  3. Kaiser S.
    Replies:
    3
    Views:
    959
  4. Vesna Sarajevo
    Replies:
    1
    Views:
    651
    Eliyahu Goldin
    Jul 30, 2007
  5. Andreea
    Replies:
    0
    Views:
    493
    Andreea
    Apr 21, 2012
Loading...

Share This Page