I want to restrict instantiation of a class to one time only.

I am developing a java application. The requirement is that only one instance of a class/application should run. Any attempt to load application twice be restricted displaying some warning message.
Please help me on this problem.

There are several ways to do this, I believe. One is
to create a specific temporary file in the file
system. as soon as the application starts. First
thing to do when the app runs (in the main method)
would be to check if that file exists. If it does,
exit the app. If not, create it then continue with
the rest of the application.
there is a second method by opening up a port or
socket. I am not familiar with this, but if you
search the forum you should find an answer...I would use ports. When an process stops it's guaranteed to release port resources. "temporary" files
can be left behind, to confuse your app the next time you run.
And just to be clear: OP, you wanted at most one copy of the app running on a given machine,
or one copying running anywhere on a network of machines?

Similar Messages

  • How do I restrict use of mac mini to one website only?

    Hi Geniuses!
    I want to set up a Mac Mini in my office that can only be used to browse 1 website and nothing else. I don't want any user other than Admin to have the ability to change any settings, download any apps, install any software or browse the net other than to the specified website we have restricted Safari or Firefox or what to.
    The website is an online testing site for my staff training program, so the user logs onto the website with his/her username and password and then can write tests online.
    I hope there are some very simple ways to achieve the above. I will be using a Mac Mini which has been set up as a server somehow and running OSX10.6.8.
    The startup disk says Server HD so not sure if I should change this machine to not be a server? Or is there a way to log into the second partition which is labelled Macintosh HD2?
    I hope to hear back from some of you soon.
    Thanks very much all.

    Thanks for that advice andyBall_uk I did look in the Library under System and found the ParentalControls.prefPane and when trying to open with System Preferences I got an error message stating:
    "You can't open the "Parental Controls" preferences pane because it is not available to you at this time.
    To see this preferences pane, you may need to connect a device to your computer."
    Any ideas as to what I may have to connect to my computer? I did not download Workgroup Manager as yet.
    Hope to hear from someone soon. Thanks, Jason

  • How do I restrict number of downloads at a single time in the download window?

    How do I restrict number of downloads at a single time in the download window?
    I want to restrict the number of downloads at a time. Other downloads should be in a queue. For example, if I restrict as 5 downloads are available at a time, the 6th download should be in a queue and should start any one of the download is completed. And the next download should resume ... and so on. So at any point of time only 5 (or it should be specified) downloads should be possible. Is there any settings can be done in FireFox for this? Please help.

    Firefox 3.0.15 is no longer supported. You should upgrade to a new version.
    http://www.mozilla.com/en-US/firefox/
    or
    http://www.mozilla.com/en-US/firefox/all.html

  • How to restrict user marking same events in multiple times.

    Hi,
    In my online exam system, I am displaying the questions and related answer in jsp page. Once user fill all this questions, the result of these stored in final table containing column questonNo, userid, answer, testname.
    Now in my application if any user goes back to the question displaying page after submitting same questions, he can change the answer selected in first attempt and submitting again the test, the result are stored in final table. I.e. for same question no. user is now able to answer in two times. I want to restrict user for answering test in second times.
    How can I achieve this?
    Any suggestion is highly appreciated?
    Thanks and Regards
    Harshal

    Hi Hari,
    with you suggested logic can i restrict user marking one question in multiple times,
    My target is once user submit any questions teh control will be transferred to the next page.Now he/she could not able to submit the same questions with another answer or the same answer also which is possible in my application by going back to these page using back button .so that i can get only one record for particular questions in table final.
    Thanks and Regards
    Harshal
    Edited by: HARSHAL_GURAV on Aug 20, 2008 12:15 AM

  • Want to restrict out of 3 @prompts

    Hi Folks,
    I have one Webi report which has 3 @prompts for Purchase order number, Serial number and Sales order number, User is supposed to enter any one value as these prompts are on OR condition. For example, I enter Serial number and rest as '*'.
    This is fine as far as i use only one prompt with a known value. But when i pull all prompts and enter any one value, report keeps running for around 8 hrs and does not product any output.
    So I want to restrict only one prompt. Like if user puts value for any one prompt, other prompts gets disabled. so Query will not perform full table scan and will search for records using only one value that is entered.
    At the same time I want to keep provision of '*' also.
    How to apply this functionality at Report level?

    Hi,
    when you say disable the prompts when user selects one of the Purchase order number, Serial number and Sales order number. what did u want? say user selects the serial number do u want to pull all records pertaining to selected serial number along with all the records related to the other fields((Purchase order number,Sales order number)) or when the user selects the serial number did u want the report to run only for the serial number selected but ignore the remaining prompts by not fetching any records for those prompts ?
    if u want to run the report only for selected prompt but not fetch any records for the remaining, u shud be passing some kind of junk values as default for the remaining prompts so that they are out of picture(but since they are in OR condition u will get only records containing the selected prompt values)
    Thanks,
    Karthik

  • My Client wants to restrict appearing used PO Line items in MIRO

    Hi Gurus
    My client wants to restrict appearing blank line items agaisnt already used Purchase Order Items (Full Qty GR / IR happened, GR Based IV) in MIRO so that user can not book another invoice against the same PO with diffrent ref. no. and in date.
    Is there any way (User Exit / Screen Variant) we can make it?
    Please reply.
    Thanks
    Sanjib

    Hi
    Even if I set Final Invoice Indicator in MIRO and booked invoice against the PO systems is showing blank line items (Amt & Qty are blank) in MIRO agaisnt the PO.
    Can you please run the scenario and tell me is there any way that we can restrict system showing blank line items against already processed PO items in MIRO. I have tried booking invoice agaisnt individual del note but blank line items are there.
    Thanks
    Sanjib

  • Want to restrict the vendor at plant level

    Hi Experts,
    As per standard SAP, once the vendor is extended to comapny code then buyer can place order in any plant of same company code. My client wants to restrict the use of vendor at plant and after some business approval, will allow to use the vendor for specifc that plant. Could you please help me, how can I acheive this ?
    Thanks in advance,
    Regards,
    Ajit

    There is no solution for you in standard you have to develop something yourself.
    It is even possible to create purchase orders before a company code view is created for a vendor master, hence it cannot be controlled via company code blocks. The block at company code will have an effect on goods receipt and invoice receipt, which is too late.
    Purchasing blocks can only be set at purchasing organisation level. Even you can create a vendor with a plant level , it is not possible to set a block at this level. If this purchasing organisation serves many plants then a block will affect all plants.
    only with a  purchasing organization specific responsible for a single  plant you can meet your requirement in standard with a procurement block at purchasing org level.

  • Want to restrict output of T.Code MD4C.

    hi friends,
    i want to restrict output of T.Code MD4C in which it displays all materials for one SO but i want to display only FERT HAlB and RAW materals. how should i do it. there is one badi  MD_ADD_COL_OVERVIEW  (Display of Additional Columns in the Material Overview  )  . is it write place to do it if yes i never use BADI so kindly can u send some information about badi and how to use it.
    thanks in advance.

    Dear Friend,
    Just go through the Sample code of that BADI.
    For more Information Just check any implementations are there for this BADI.
    With Regards,
    Sumodh.P

  • Want to restrict user form putting any value in condition in po

    Dear all,
    ply help on this matter.
    i want to restrict person for put any value in condition tab for po.
    let say i am putting "FRC1" condition and value let say 5rs then i should get an error saying your are not authorised.
    puprose:condition like FRC1 ETC should not be allowed to change.
    regards
    amey

    Hi,
    To restrict any manual entries for a Condition type, In that condition type under Changes which can be made maintain 'D' for Manual entries option.
        Along with this maintain the condition record for that perticular vendor for the amount which has to be paid for Freight.
    Regards,
    Vijay

  • Want to restrict data in T.code MD4C

    hi friends,
    i want to restrict output of T.Code MD4C in which it displays all materials
    for one SO but i want to display only FERT HAlB and RAW materals. how should
    i do it. there is one badi MD_ADD_COL_OVERVIEW (Display of Additional
    Columns in the Material Overview ) . is it write place to do it if yes i
    never use BADI so kindly can u send some information about badi and how to
    use it.
    thanks in advance.

    hi,
    BADI you mentioned is not present in Definition view ie se18.
    To implement BADI using se19 you need to check 1st wether it is present in definition view.
    Once you find appropiate BADI you will have to write code in its interface method.
    For this purpose you should be aware of ABAP OOPs concept.
    Regards,
    SUDHIR

  • N00b query: Why would anyone ever want to define their own Exception class?

    I've been reading thru my Java textbook for the past couple hours.
    Exceptions are a wonderful thing. I already found several instances where I could've implemented try/cacth in my earlier programs.
    Anyway, getting back to the point. My question is, can someone give me a realistic situation/example where a custom Expcetion class is REQUIRED? (the key word here is "required"!)
    I can see why someone would want to have his own Exception class..... e.getMessage() as custom error messages are SO DAMN COOL!!!!!! :P
    hehe
    But seriously, if you are making intermidiate/advanced Java programs, would you ever REQUIRE to make your own Exception class? Afterall, even a custom made Exception class always "extends" from a pre-defined Java class, right?
    Let me make this a bit more clear... public class CustomException extends IOException{  }Now, if I am making a try/catch statement, I can simply say
    try{
    throw new CustomException;
    catch (IOException e) { }
    Now as you can see, the CustomException was caught by the catch claus, because IOException is the superclass of CustomException. So, in other words, the whole CustomException thingy didnt do anything useful.
    I know I know, I am so naive. Enlighten me >.<

    Sure. Say you want to have a system where you want to include a custom error code which maps to some internationalized error messages. You would create an Exception subclass with a field to hold that value separate from the normal "default" message. Then you could throw that exception in all your code. Other code can catch it as a plain Exception if they want and use the "default" message, which is okay if they don't really care about the error code.
    I don't think you are ever "required" to make your own exceptions. I have done so, but I don't often. It depends. See, there are plenty of Exception subclasses in the standard packages, and most of them cover many of the things you need. So more often if I'm throwing an exception, I'll be using the already existing ones, like IllegalArgumentException or IOException (whatever is relevant to the code).
    Yes, you can do what you did below with CustomException. However the reason you might do that is cuz you really want to do this:
    try {
       // call some code that may throw IOException from some standard IO package
       // or may throw CustomException from some of my methods...
    } catch (CustomException ce) {
       // handle cusotm exception
    } catch (IOException ioe) {
       // handle IO exception
    }Cuz you may want to differentiate between your exceptions vs. IOExceptions that might be thrown from some java.io class.
    Usually when you use an exception class it's a named class that relates to some condition. It may hold additional information besides the standard message, but I think most of the time it's just the class name which describes the problem. And if there isn't one that describes the problem that you're code might encounter, then create a subclass.

  • I have a problem how can I solve it I want give permissions to groupA to edit the people picker and I want to restrict groupB to edit the people picker what is the solution boss.. in InfoPath form is it possible..

     i have  a problem how can I solve it I want give permissions to groupA to edit the people picker and I want to restrict groupB to edit the people picker what is the solution boss.. in InfoPath form is it possible..

    Hi,
    To hide/disable controls based on user group in an InfoPath form, a solution is that we can call User Profile Service to check the group of current user, then hide/disable
    specific controls by setting some rules in form.
    Here is a demo with steps in details would be helpful to you:
    http://blog.symprogress.com/2011/05/infopath-list-form-hidedisable-fields-based-on-sharepoint-group-membership/
    More information about checking if a user is a member in a SharePoint group within web InfoPath 2010 forms:
    http://www.hishamqaddomi.ca/spg/index.php/sharepoint-2010/infopath-2010/65-checking-if-a-user-is-a-member-in-a-sharepoint-group-within-web-infopath-2010-forms
    Thanks 
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Want to restrict infotype maintainance 9(Bank Detail) for  withdrawn emp

    Hi Experts,
    I want to restrict the maintainance of infotype 9 for withdrwan employee, either this has to be done through configuration or writing code in module pool of infotype 9.
    Thanks in Advance.
    Regards,
    IFF

    hi,
    there will be one field   Maint.aft.leave under general Attributes.. This field controls whether you can record master data after an employee has left the company. A warning tells you whether you are permitted to do so or not.
    Regards,
    Kapil

  • I want to restrict my database

    hi
    I have a oracle enterprise 8 on my server machine. There are five user connected to the server through the peer to peer basis. I want to restrict my database on server. I want that user can only connect through the forms but they cannot be connected through any promt (i.e. SQL, PL/SQL, or Worksheet). Simple is that i want that the users only can connect with my server through forms only.
    plz help me, its crucial for me.

    CREATE OR REPLACE TRIGGER NOTOAD_VB AFTER LOGON ON DATABASE
    DECLARE SHOULD_EXECUTE INTEGER;
    BEGIN
    SELECT DECODE(SUBSTR(UPPER(PROGRAM),1,4),'TOAD',1,'VB',1,0)+DECODE(INSTR(PROGRAM,'\',-1),0,0,
    DECODE(SUBSTR(UPPER(SUBSTR(PROGRAM,INSTR(PROGRAM,'\',-1)+1)),1,4),'TOAD',1,'VB',1,0))
    INTO SHOULD_EXECUTE FROM V$SESSION WHERE SID=(SELECT SID FROM V$MYSTAT WHERE ROWNUM=1);
    IF SHOULD_EXECUTE > 0 THEN
    raise_application_error(-20001,'Please no toad and VB yet, try again later');
    -END IF;
    END;

  • Wanted to restrict sales order for a particular region

    Hi all
    I want to restricted two sales order on the region parameter,while using same sales area.
    Ex:
    sales order A should be used in delhi region,where as sales order B should be used for outside delhi,though the sale area is same for both the order type.
    Hope my problemis clear to all.
    Thanks
    siddharth

    Dear Siddharth
    You can try with any of the following user eixts
    -  User exits in the program MV45AFZZ - USEREXIT_READ_DOCUMENT
    -  User exits in the program MV45AFZZ - USEREXIT_SAVE_DOCUMENT_PREPARE
    -  User-Exits in program MV45AFZB - USEREXIT_CHECK_VBAK
    thanks
    G. Lakshmipathi

Maybe you are looking for

  • Safari won't open on my iPhone 4 how do I fix it

    Safari won't open when I click it it goes off and returns to home page how do I fix this problem?

  • Transfering music from iphone to Macbook

    My old macs hardrive crashed but i had all my music on there so i need to get it back onto my computer. I still have the music on my iphone though, so is there an application that will help me do this? I've been looking for a while but i cant find on

  • Can't install iTunes + Quicktime

    Just got a ipod nano.. when i try to install i-tunes it says Couldnt install geardrivers? try again after restart.. but it doesnt work after restart. what to do?

  • Are the forum RSS feeds broken again?

    W3C validator says the RSS feed - for example for this forum - 'does not validate'. Thunderbird also complains that the feed is invalid. Jonathan.

  • Hardcode and open source

    technically, what does hardcode and open source mean? And, jasper reports and ireports, they are used for report generation in java ryt? is report generation a separate process? or is it embedded in a java app?