Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29
  1. #21
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Bottom line, it can't be done
    Did you miss this technique?
    URL ourLoc = obj.getClass().getResource(className);
    Print out the value of ourLoc to get a String with the path to jar file the className is in.

  2. #22
    JonJacobs is offline Member
    Join Date
    Jul 2010
    Posts
    34
    Rep Power
    0

    Default

    URL ourLoc = obj.getClass().getResource(className);
    Print out the value of ourLoc to get a String with the path to jar file the className is in.
    Aha! Thank you. I'll try that.
    Did you miss this technique?
    I guess so. I looked carefully over the thread, and this is the first it has appeared.

    Thank you much,
    Jon Jacobs
    This message was composed entirely from recycled electrons.

  3. #23
    JonJacobs is offline Member
    Join Date
    Jul 2010
    Posts
    34
    Rep Power
    0

    Default

    Did you miss this technique
    Oops. I see it now. You had it right in an early part of this thread, and I indeed missed it.

    Thanks again,
    Jon Jacobs
    This message was composed entirely from recycled electrons.

  4. #24
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Quote Originally Posted by JonJacobs View Post
    Yes, but only one time.

    I only want to do it once.

    In my environment, there is a reason, which I won't go into. If not the jar-file name, then some other name unique to the jar-file, programatically obtainable, and not hardcoded in the app or in an external file. BTW, I name my properties file the same as the jar file, and my app can't find it unless it knows the name.
    I'm sorry to belabour the point, but there is nothing about a jar file that requires its name to be unique compared to other jar files.

    As for "only once" you only have to write the code to read a property file once. Have a standard name and location in the jar for it, and all you have to do is stick the name in it in a standard place. One property file template...boom...there you go...just as easy as coming up with a name for the jar file. You could even go the whole ant build thing and have it populate that property file for you (which we do here for our db connections). So you don't even have to do that bit each time. Standard build script, standard property file.

    But hey, you don't care how it's done anywhere else so I suppose this is moot.

  5. #25
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Maybe the OP likes this little trick (if really needed):

    Java Code:
    String name= new Exception().fillInStackTrace().getStackTrace()[0].getClassName();
    kind regards,

    Jos

  6. #26
    JonJacobs is offline Member
    Join Date
    Jul 2010
    Posts
    34
    Rep Power
    0

    Default

    Maybe the OP likes this little trick (if really needed):
    Thanks, I'll take a look at that.
    Jon Jacobs
    This message was composed entirely from recycled electrons.

  7. #27
    JonJacobs is offline Member
    Join Date
    Jul 2010
    Posts
    34
    Rep Power
    0

    Default

    there is nothing about a jar file that requires its name to be unique compared to other jar files.
    True enough. There's nothing about an exe file that requires its to be unique either. But I get the point.

    Thanks,
    Jon Jacobs
    This message was composed entirely from recycled electrons.

  8. #28
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    A technique I use to automatically have different user ids for the same program, is to use shortcuts and add the user's id as an arg on the command line in the shortcut. Each user has his own shortcut to the same program.

  9. #29
    JonJacobs is offline Member
    Join Date
    Jul 2010
    Posts
    34
    Rep Power
    0

    Default

    A technique I use to automatically have different user ids for the same program...
    Ah, a technique worth noting. Thanks,
    Jon Jacobs
    This message was composed entirely from recycled electrons.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. java,jsp code to create a website statistics application
    By g.shashikala in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-15-2009, 05:00 PM
  2. Code for adding search function in an application
    By Avdhut in forum Threads and Synchronization
    Replies: 5
    Last Post: 03-03-2009, 10:15 AM
  3. [SOLVED] Running Code in my own application
    By Doctor Cactus in forum New To Java
    Replies: 4
    Last Post: 02-18-2009, 08:38 PM
  4. organizing larger application code / modules
    By zenner in forum Advanced Java
    Replies: 5
    Last Post: 07-28-2008, 09:18 AM
  5. EventHandling code for Swing application
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-07-2007, 12:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •